You need to sign in to do that
Don't have an account?
ABC XYZ 39
Use RecordType Name in Triggers.?
Hi, I need to return only specific records by recordtype name. How do I implement this in trigger . Thanks
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Some time in code we need to get recordTypeId . For that generally we used SOQL like below :-
You can try below Describe to get record Type Id without SOQL
Sample Trigger code for you.
PLease let us know if this will help you
All Answers
RecordType rt = [SELECT Id, Name FROM RecordType WHERE Name = 'Your Record Type Name'];
In your trigger you can filter on your records by simply Where RecordTypeId = rt.Id;
Please let me know if you face any issue..............
You can achieve this using below mentioned 2 approaches:
1. Fetch the record type Id using SOQL:
RecordType rt = [SELECT Id FROM RecordType WHERE DeveloperName = 'RecordTypeAPIName'];
2. Using desribe call:
Id devRecordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('recordtypenamelabel').getRecordTypeId();
Using 2nd approach your one SOQL usage will be prevented.
Some time in code we need to get recordTypeId . For that generally we used SOQL like below :-
You can try below Describe to get record Type Id without SOQL
Sample Trigger code for you.
PLease let us know if this will help you