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
Kapil KaushikKapil Kaushik 

Modify Permissions Set using Post Install Script

We can modify the Permission Sets using Apex in our Development org.
But can we change the Permission set by writing code in the Post Install Script after package Installation without cloning Permission sets ?
Best Answer chosen by Kapil Kaushik
Kapil KaushikKapil Kaushik
Thanks @Anup Jadhav for you help.

We can not modify the Permissions Set if these are the part of package.
But we can Insert new Permissions Set by Using Post Install Script.

I have Implemented this and my Permissions Set includes:
App permission
Apex Page & Apex Class
Objects & Field Permissions and may more.

If someone needs any help on Permissions Set ( of Standard Objects when these are the part of Package and having Master-Detail relationships with our Custom Objects), Please feel free to post your Comments on this post.

Thanks,
Kapil Kaushik

All Answers

Anup JadhavAnup Jadhav
I don't have massive experience with this but I believe this is doable. A bit of googling gives a few links and one of them does show an example of setting permissions set in post install script.

https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/push_upgrade_post_install_script.htm 

Hope this helps!
Kapil KaushikKapil Kaushik
Thanks @Anup Jadhav for you help.

We can not modify the Permissions Set if these are the part of package.
But we can Insert new Permissions Set by Using Post Install Script.

I have Implemented this and my Permissions Set includes:
App permission
Apex Page & Apex Class
Objects & Field Permissions and may more.

If someone needs any help on Permissions Set ( of Standard Objects when these are the part of Package and having Master-Detail relationships with our Custom Objects), Please feel free to post your Comments on this post.

Thanks,
Kapil Kaushik
This was selected as the best answer
devcoolgauravdevcoolgaurav
@Kapil Kaushik Could you please share your code for adding App permission to Permission set via apex
George GeorgeGeorge George

Can we run scripts on Profiles?

I have installed a Manage Package for all profiles in the Org, now I want to restrict the package access only to certain profiles ? 

Instead of doing for each profile manually do you have any automated solution?