How to assign a permission set in apex?
PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = ‘XXXXXXXXXXXc94’, AssigneeId = u.Id); permissionSetList.add (psa); } upsert permissionSetList; } } Trigger. Thanks! You need to create a @future method and call it from your trigger.
How to find user assigned with particular permission set?
I know that that this PS is assigned to few user’s but when queried, the query returned 0 results. Make sure you are passing the API name of permission set in query. Did you use the Permission Set API name in the query ? Thus you will receive a result containing all the permission set names. Thanks, previously I queried wrongly.
How to find the permission set API name?
Make sure you are passing the API name of permission set in query. Did you use the Permission Set API name in the query ? Thus you will receive a result containing all the permission set names.
How to set parent profileid in apex class?
AND Parent.ProfileId IN (SELECT Id FROM PermissionSet WHERE PermissionSet.Profile.Name = ‘System Administrator’). Hope this ans helps you, if it does select it as best answer. You can also refer to https://developer.salesforce.com/forums/?id=906F00000005HTsIAM.
Can you set an apex class to run?
However, to make sure that confidential data is not accessible for users that are not supposed to have access to it, you can set an Apex class to be run considering the privileges, sharing rules, levels of access to the fields by the user, under whose name the class was launched. This can impact SOQL, SOSL, and DML expressions.
How to set FLS for field from apex class?
I can’t set FLS for field from apex. You can get field permissions and set each permission by setting them to ‘true’/’false’. Adding sample code for setting permissions for each field of opportunity sobject and you can check for profile by adding below query to list rt query.