New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :

Friday, 26 December 2014

Fetching Record Type Id with Dynamic Apex

recordTypeInfo Utility Method
  public class MyUtility {
      @ Description -
      To fetch the RecordType Information of a certain Object.
      @Usage -
      Using this approach, we can avoid writing SOQL queries in apex class/test class to fetch the record type Id.

   /*** recordTypeInfo Utility Method ***/
   //Below method will take sObject API as input.
   public static Map recordTypeInfo(String objectApiName){
    Map sObjectMap = Schema.getGlobalDescribe() ;
    Schema.SObjectType sObjType = sObjectMap.get(ObjectApiName) ;
    Schema.DescribeSObjectResult sObjTypeDescribe = sObjType.getDescribe() ;
    //returns all the record types info for a certain object
    return sObjTypeDescribe.getRecordTypeInfosByName();
  //---End of the Logic---Please ignore remaining lines---

recordTypeInfo Utility Method - Usage
  /*** recordTypeInfo Utility Method - Usage ***/

  //To retrieve the recordTypeId of a RecordType 'Sample Record Type' which belongs to 'Case' object.
  Id sampleRtId = MyUtility.recordTypeInfo('Case').get('Sample Record Type').getRecordTypeId();

  //Result: 'sampleRtId' will fetch the recordTypeId of 'Sample Record Type' record type.


  1. Use return type as Map and return sObjTypeDescribe.getRecordTypeInfosById(); to get the record type name based on the record id.

    1. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.

      Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.

      Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

      The Nodejs Projects Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Awesome Blog, you have provided the right information that will be beneficial to us. Thanks for sharing your valuable Ideas to our vision. Linux Training in Chennai | Unix Training in Chennai | Python Training in Chennai

  3. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. 
    Android Training Institute in Chennai | IOS Training in Chennai