Play Games

Search This Blog

Sunday, September 6, 2020

System.NoAccessException: Apex approval lock/unlock api preference not enabled - Salesforce Globe For You

System.NoAccessException: Apex approval lock/unlock api preference not enabled  - Salesforce Globe For You 

Problem:when you try to use lock/unlock/lock status(isLocked) related methods of Approval class,you get the above error.

Example:run the below piece of code ,it will result in the above error if 'Enable record locking and unlocking in Apex' checkbox is false.

List<Lead> lstLead = new List<Lead>();

lstLead = [Select id,name from Lead For UPDATE];

System.debug('lstLead'+lstLead);

Map<Id,Boolean> recordMap = new Map<Id,Boolean>();

recordMap = Approval.isLocked(lstLead);

Solution:Enable the 'Enable record locking and unlocking in Apex' checkbox by navigating to Setup--> Create -->Process Automation Settings as shown in the image below.



No comments:

Post a Comment