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
Piotr B. KożuchowskiPiotr B. Kożuchowski 

What is the proper approach for deploying custom Auth. Provider in Salesforce DX?

I have a custom Auth. Provider and a couple of Named Credential which use it.
The auth. provider metadata requires "Execute As" field which is represented as username in metadata and as you know,
usernames are globally unique in Salesforce.

So the deployment will always fail, because user will never exist on another sandbox and at the same time, the username field cannot be left 
empty.

What is the proper approach in this case in source driven development?

For now, I will have to run a script which replaces username when new scratch org is created and when source is deployed to staging environments. It's obviously far from perfect solution, because my teamies will have to use custom script instead of sfdx force:org:create and because the username change will be visible in VCS every time someone creates a new scratch org.

I really hope someone from Salesforce DX development team will see this.
Deviprasad Hegde 30Deviprasad Hegde 30
Is this still an issue ?It worked for me without changing the execution user in the auth provider . The custom auth provider automatically takes the target org user while deployment.