Salesforce Fact #656 | Inserting data into SetupEntityAccess

Similar to retrieving data, we can insert rows using apex as well in SetupEntityAccess object for custom permission.

Example code:

SetupEntityAccess sea = new SetupEntityAccess();

sea.ParentId='0PS6F0000057tXt'; // this is the permission set Id

sea.SetupEntityId='0CP6F000000XkviWAC'; // this is the custom permission Id

insert sea;

Note: If an attempt is made to insert row for an already existing combination, the error 'DUPLICATE_VALUE, duplicate value found:' is shown.


Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow