Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.
Electron asked in #Apex

I want to use record Type to limit trigger action. 

 

Now I use querey to get it my code liks below

string Id = [SELECT id from RecordType where Name ='Someone'].Id;

 

I also found this page, we could use method to get the Record Type Id to avoid the query.

I still can't understand it.

 

Is there some simple and easy wayt to get the ID only by Record Type's Name?

16 answers
  1. May 8, 2013, 8:24 AM

    You can use:

     

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

     

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

     

    Thanks,

    Vagish

Loading
0/9000