function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saravana Muthu 8Saravana Muthu 8 

APEX CPU LIMIT EXCEEDED only in Salesforce Classic

Hi All,

Requirement:

For every Account a client wants us to target we ‘tag’ them by creating a custom field named after the client name.

For example, if ‘Client A’ wants us to target Tesco, then we would create a field called ‘Client A’ and on the ‘Tesco’ account page, populate this field with a ‘Yes’.

We need a way to tag every account a client wants us to target without creating a custom field.

As well as tagging the account, the tag should tag every contact related to that account as well.

We need to be able to report on these ‘tags’. I.e. we need to be able to
pull a list of accounts and/or contacts when we need to.

How we have achived it:

We have created a code to create record in a custom object whenever a field in Contact record has updated.

The record creation fails in classic and but this is working good in lightning.

We got the below error when save the record, Screenshot below,

User-added image

Could somone please help resolving this issue?

NOTE:This is only fails in salesforce classic.

Thanks,
Sarav
Deepali KulshresthaDeepali Kulshrestha
Hi Saravana,

Salesforce has a timeout limit for transactions based on CPU usage. If transactions consume too much CPU time, we'll shut them down as a long-running transaction

Go through with this link and have a look at best practices to reduce CPU timeout

https://help.salesforce.com/articleView?id=000339361&language=en_US&type=1

Please check below post, to resolve this issue

http://salesforce.stackexchange.com/questions/22223/how-to-code-more-efficient-to-avoid-apex-cpu-time-limit-exceeded

http://salesforce.stackexchange.com/questions/47035/errorsystem-limitexception-apex-cpu-time-limit-exceeded

Also, look into some of the posts on the same topic:

https://developer.salesforce.com/forums/?id=906F0000000BQcyIAG


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.