HI Friends ,
In this I am going to demonstrating the sample mechanism to get record types for the particular object in to apex.
1. Using describe object , we can get Record Types Names and Record Type Ids .Below is the example,
String StrRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Business').getRecordTypeId();
The above code returns the record type id of the Business record type.
2. Another way to get Record type is query on the Record Type object .
Select Id From RecordType where sobjecttype = 'Opportunity'
The above query gives us all record types defined on the opportunity object.
Hope above 2 are use full.
Thank you.
In this I am going to demonstrating the sample mechanism to get record types for the particular object in to apex.
1. Using describe object , we can get Record Types Names and Record Type Ids .Below is the example,
String StrRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Business').getRecordTypeId();
The above code returns the record type id of the Business record type.
2. Another way to get Record type is query on the Record Type object .
Select Id From RecordType where sobjecttype = 'Opportunity'
The above query gives us all record types defined on the opportunity object.
Hope above 2 are use full.
Thank you.
No comments:
Post a Comment