You need to sign in to do that
Don't have an account?
Agustina Garcia
Assign Permission Set to Connected App via code
Hi there,
My org has a PS and a Connected App and I would like to write a piece of code that do the assignment for me after installing a package.
Running this piece of code from Dev Console, I get it work
However it doesn't work from instalation script. In order to test it quickly I also created tab related to a VF page with a button that calls this code and it neither works.
I guess the reason is that Dev Console has more priviledges to run code rather than vf page or post instalation script. But I would like to find a way to make it work
Thanks!
My org has a PS and a Connected App and I would like to write a piece of code that do the assignment for me after installing a package.
Running this piece of code from Dev Console, I get it work
SetupEntityAccess sea = new SetupEntityAccess( ParentId = ps.Id, SetupEntityId = connectedApp.Id ); insert sea;
However it doesn't work from instalation script. In order to test it quickly I also created tab related to a VF page with a button that calls this code and it neither works.
I guess the reason is that Dev Console has more priviledges to run code rather than vf page or post instalation script. But I would like to find a way to make it work
Thanks!
I have not checked this but can you try using the runas below is the link for implementation I hop this helps.
>>https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm
Regards,
Anutej
Thanks for your response but I think you can only use runas during testing. Your link is also under that section.
Regards
Agustina
>>https://success.salesforce.com/ideaView?id=08730000000a16jAAA
In case if this comes to use can you please choose this as the best answer so that it is easily accessible to others in the future.
So, at this moment, June 2020, there is no way to run apex code as system admin, but I will follow the idea (https://success.salesforce.com/ideaView?id=08730000000a16jAAA) you found just in case it changes in the future.
Regards,
Agustina