
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
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