In one of the triggers, they have hard coded the userid, as below. How can we avoid this?
if(currentUser != '012300000012345PPPP' && Utils.isS == false)
{
//DO SOMETHING
}
In one of the triggers, they have hard coded the userid, as below. How can we avoid this?
|
|||||
|
If you do not want the user id to be hardcoded as a string in Apex code then you should create a custom setting and then you can query the value in the trigger.
When the special user changes you can update the user id on the custom setting. Without modifying source code. You could also use a Custom Permission and Permission Set to control access to a section of code. Create a Custom Permission 'Special User' assign to a permission set 'Special User Rights'.
|
|||||
|
Another option that avoids the custom setting would be to create a role, put the single user in the role, and then query membership of the role using the DeveloperName of the role. |
|||||||||||||||||
|