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.

  • 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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.