3

I have an issue where a some reports and a custom report folder were created in production but I need to add them to version control so that it can be properly managed within the source of truth. I have pulled down the metadata and convert it to source where it now resides in the following:

force-app/main/default/reports/Custom_Reports.reportFolder-meta.xml

Unfortunately when I attempt to push this to a scratch org like so:

sfdx force:source:push -u test

I get the following error: In field: sharedTo - no User named [email protected] found

The obvious answer seems to be that my email is stored directly in the metadata like so:

<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
    <folderShares>
        <accessLevel>Manage</accessLevel>
        <sharedTo>[email protected]</sharedTo>
        <sharedToType>User</sharedToType>
    </folderShares>
    <name>DPC Reports</name>
</ReportFolder>

So how do I work around this? The data setting is stored in the metadata and that value is going to change from org to org so I will have deployment issue every time if the org doesn't contain that user email.

2 Answers 2

0

If you really need a user and folder permissions then execute the below command to create a user in the scratch org with same username before you run sfdx force:source:push

sfdx force:user:create [email protected] email=<emailofuser>

Alternatively you can make it public Folder just to get the scratch org creation going .

To do this modify your metaxml for ReportFolder as below

<?xml version="1.0" encoding="UTF-8"?>
  <ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
    <accessType>Public</accessType>
    <publicFolderAccess>ReadWrite</publicFolderAccess>
      <name>DPC Reports</name>
  </ReportFolder>

In your PROD org or packaging you can manually turn on Sharing via config.

5
  • Anyway to get around the following error? ERROR: There are no available user licenses for the user profile "Standard User" Mar 3, 2018 at 0:45
  • Sounds like you don't have enough license for that .How many users have you created in scratch org ?Scratch orgs have limited licenses Mar 3, 2018 at 0:46
  • There is a pilot program for org shape, you can use that to get an org replica of your PROD org . Mar 3, 2018 at 0:50
  • I'm in the pilot and I'm using it effectively but this is not something that it handles. The users created have a randomly generated alpha# and domain is replaced with "example.com" like this [email protected] Mar 14, 2018 at 21:36
  • Actually that is the username... the email is just domain replacement: [email protected] Mar 14, 2018 at 21:41
0

You could first pull up data from your production using sfdx tree export commands and some admin users and/or since you're getting in to issues while creating new users as suggested by Mohith in his answer above for the time being you could open up a text-editor like Sublime and find and replace all occurrences in all files inside src folder of [email protected] with your scratch org username.

I know it's not the most elegant solution out there but at least gets rid of the deployment errors. If you're using a CI system, you could configure a shell script to do the same for you.

For advanced uses you could come up with a regex for matching *@mydomain.com and then replace all the occurrences with a single click. Sublime's find and replace features are really mature and could help you with this in minutes.

You must log in to answer this question.

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