function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chang Sun 6Chang Sun 6 

Different ways to create permission sets

There are two ways to create permission set, but we are wondering which way is better and more sustainable.

1) Using Apex class to create a post install script and using query to add permission sets as well as the fieldAccess, classAccess, objectAccess etc.
2) Using standard customPermissionSet.permissionset-meta.xml to define a permission set with all settings in the same file.

Does anyone have any experience on which way is better? And what is the pros and cons for each method? Thanks!
VinayVinay (Salesforce Developers) 
Hi Chang,

You can use metadata api using meta.xml.

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_permissionset.

Thanks,
Chang Sun 6Chang Sun 6
Thanks Vinay,

Yes, using meta.xml file is one of our option(point 2 in my previous post) But Salesforce does allow user to use APEX class to create a permission set. We are trying to figure out if that way is better or what is the pros and cons for that method.

Thanks,