Activity › Forums › Salesforce® Discussions › What is the method we can use to get the Record Type Id in Salesforce?

  • madhulika shah

    Member
    August 3, 2018 at 12:35 PM

    Hello Shradha,

    If we want to avoid the query we can use:

    Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Development').getRecordTypeId();

    Here, 'Development' is the record type's name. You should use anything. Also, you will have to specify your SObject type, here I have mentioned Account.

  • [adinserter block='9']
  • shariq

    Member
    September 18, 2018 at 10:48 PM

    Hi,

    There are two ways to do it -

    • Query on record type by its developer name
    • Id recId = Schema.SObjectType.Object__c.getRecordTypeInfosByName().get(‘recordTypeDeveloperName’).getRecordTypeId();

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Salesforce Admin Certification 2020 Questions Explained with References - Part II

Video in

How to prepare and pass Salesforce Admin Certification with Practice Exam Questions 2020 practice questions and answers for the Salesforce Administration Salesforce Certified Admin Exam Questions Salesforce Administrator Certification Exam…