You need to sign in to do that
Don't have an account?

how to get my record type name in before insert in apex
Hi,
How to get the record type name in before insert.
Requiremnet is need to check in if condition for record type name
Ex : if(record type name= 'A' )
How to get the record type name in before insert.
Requiremnet is need to check in if condition for record type name
Ex : if(record type name= 'A' )
You need to compare Obj.RecordTypeId with Actual RecordtypeId, as we cannot find RecordType.Name directly in new list without querying it.
Please follow this:
Hope this is useful
Thanks,
Gaurav
All Answers
Lets say you are working on Lead object and you want to execute some code for specific record Type.
Please mark as best answer if helped.
Regards,
Ramakant
I tried the below code, but it is not working . please correct me if I were wrong
for(Case currCase : trigger.new){
if(currCase.recordType.Name == 'Certificate of Purchase Assignment form' )
{
currCase.Check_Legal_Description__c = true;
}
in your if condition use recod type API name, not lable name :
Not record type lable ,
Thanks, let us know if it helps you.
You need to compare Obj.RecordTypeId with Actual RecordtypeId, as we cannot find RecordType.Name directly in new list without querying it.
Please follow this:
Hope this is useful
Thanks,
Gaurav
Can we capture the recordtypeid before saving the new opportunity in the controller class?
Thanks,
Ravi
RecordType is always available you just need to fire the below statement to get the value.
Schema.SObjectType.OBJECTAPIName.getRecordTypeInfosByName().get('RecordTypename').getRecordTypeId()
Thanks,
Gaurav