Category Archives: Salesforce

How to get a RecordType Id by Name without SOQL?

Sometimes in apex we required RecordType Id of an object by its Name. So, here is an example how we can find RecordType Id by Name.

In below example BankAccount__c is the custom object and “Savings Account” is one of the RecordType Name of BankAccount__c object. Now without SOQL I’ve to find “Savings Account” RecordType Id.

String recordTypeName = 'Savings Account';

Display all the fields of a sObject using Apex & Visualforce Page

Apex Code:

public class  DisplayAllFieldsClass {
     public map<string,schema.sobjectfield> data {get;set;}
     public  DisplayAllFieldsClass (){
         data = Schema.SObjectType.BISWAJEET__Student__c.fields.getMap();

Visualforce Page Code:

<apex:page doctype="html-5.0" showheader="false" controller="DisplayAllFieldsClass">
    <apex:datatable value="{!data}" var="d">
             <apex:column headervalue="Field Name">