Sunday, 29 June 2014

Record Type Id without SOQL query

Hi,

We have getRecordTypeInfosByName() method to get record type id with out SOQL query.
We can avoid SOQL query on RecordType object with this method.The following example shows how to access Record Type information through dynamic apex.

Schema.DescribeSObjectResult resSchema = Account.sObjectType.getDescribe();
//getting all Recordtype  Account
Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); 
//Getting Business Record Type Id
Id rtId = recordTypeInfo.get('Business').getRecordTypeId();

No comments:

Post a Comment

Best Practices for Building Prompt Templates

 Hi, The following best practices should be considered when building prompt templates: Make sure that your prompt templates are concise and ...