8

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.

2
  • Have you found any solution or architecture to avoid this problem?
    – jeromegv
    Feb 11, 2020 at 0:58
  • @jeromegv Yes. Ditch Auth provider and authenticate through code... I don't think I have ever received response from Salesforce Support on that matter (or at least I cannot see it in my email history - they might have responded with "WAD" as usual) Feb 12, 2020 at 8:21

1 Answer 1

0

Salesforce has updated their Known Issues W-4943170 to mention that a solution was coming in the Summer 2024 release

https://issues.salesforce.com/issue/a028c00000qQ258AAC/error-when-deploying-authproviders-into-sandbox-or-dx-scratch-org

This is explained here in the release notes:

Distribute Named Credentials with Second-Generation Managed and Unlocked Packages https://help.salesforce.com/s/articleView?id=release-notes.rn_security_named_credentials_managed_packages.htm&release=248&type=5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .