You need to sign in to do that
Don't have an account?
Ignore locked records in SOQL query
Hi all,
I've got an Apex class which updates a specific field in all cases every hour. A "problem" occurs with locked cases (cases open with agents).
The casefield is updated through the batchrun But when the case is opened by the agent before the batchrun and closed after the batchrun, the agent gets the errormessage that the case can't be saved because it was edited by .....
Is there a possibility in the Apex code to check in the query if a case is locked by an user, and if so exclude them from the queryresults and avoid the problem described above?
Regards
Chiel
I've got an Apex class which updates a specific field in all cases every hour. A "problem" occurs with locked cases (cases open with agents).
The casefield is updated through the batchrun But when the case is opened by the agent before the batchrun and closed after the batchrun, the agent gets the errormessage that the case can't be saved because it was edited by .....
Is there a possibility in the Apex code to check in the query if a case is locked by an user, and if so exclude them from the queryresults and avoid the problem described above?
Regards
Chiel
You can add the lock to the records currently being edited but not sure if that's possible to track what all records are locked.
Another way to implement this is create a checkbox field (isEditied) on Lead and set it true whenever Edit button is clicked and set it false whenever lead is saved.
And in your query you can exclude the Lead whose isEditied is True.
Thanks for your reply. If it can't be done solely in the Apex code, i will try the checkbox solution.
Regards
Chiel