You need to sign in to do that
Don't have an account?
SFDC ROCK
Getting System.LimitException: Apex CPU time limit exceeded
Hi All,
Getting below error when inserting 100 records
System.LimitException: Apex CPU time limit exceeded
String ob= Schema.getGlobalDescribe().get('Opportunity').getDescribe().getRecordTypeInfosById().get(opp.RecordTypeId).getName();
if(ob=='oops'){
//updating one field
}
Any alternate way to get recordtype name ? or other way to write above code ?
Getting below error when inserting 100 records
System.LimitException: Apex CPU time limit exceeded
String ob= Schema.getGlobalDescribe().get('Opportunity').getDescribe().getRecordTypeInfosById().get(opp.RecordTypeId).getName();
if(ob=='oops'){
//updating one field
}
Any alternate way to get recordtype name ? or other way to write above code ?
Try to check debug logs which gives more information on CPU time.
Review below link and follow steps mentioned.
https://help.salesforce.com/articleView?id=000339361&language=en_US&type=1&mode=1
Thanks,
Vinay Kumar
1. SELECT Id, Name, DeveloperName, SobjectType FROM RecordType WHERE SobjectType='Contact'
2 SELECT Id, RecordtypeId, RecordType.name FROM Account where Id = '<your id>';
If you are only testing the records for a particular recordType, (which it seems as you are doing it via name), consider if the Schema call can be done outside the for loop. and you test inside the loop using the Id, not the name. You can still make it portable because you set the Id value outside the loop using the Schema methods
Then in your loop test against rtId
Regards
Andrew