0

When attempting to package a report that contains a field to field comparison is shows the unique Id of the field in the metadata as opposed to the field API name.

This means that it cannot be stored SFDX format and deployed to scratch orgs or packaged since the unique Id will vary by org.

I've been unable to find any documentation related to this scenario. Wondering if anybody has seen this before or if there is a way to directly update the metadata with an API name instead?

metadataExample

errorMessage

2 Answers 2

1

Confirmed with Salesforce support that this is a limitation in the retrieval of metadata but it's undocumented.

So where the report contains a field to field comparison e.g.

<filter>
<criteriaItems>
<column>Item__c$End_Date__c</column>
<columnToColumn>true</columnToColumn>
<isUnlocked>true</isUnlocked>
<operator>greaterThan</operator>
<value>072Hy000005xaea</value>
</criteriaItems>
<language>en_US</language>
</filter>

you need to directly edit the metadata to this...

<filter>
<criteriaItems>
<column>Item__c$End_Date__c</column>
<columnToColumn>true</columnToColumn>
<isUnlocked>true</isUnlocked>
<operator>greaterThan</operator>               
<value>Item__c$Header__c.End_Date__c</value>
</criteriaItems>
<language>en_US</language>
</filter>

after which it will deploy other Orgs and allow for packaging.

0

We built a feature in CumulusCI to handle this type of situation in metadata. The CumulusCI deploy task (which loads metadata into an org) allows you to specify one or more transforms to be applied to the metadata before deployment. One of these transforms uses an XPath locator to identify locations in the XML and replace their content with the result of a query run against the target org. From the documentation:

    - transform: find_replace
      options:
          patterns:
              - xpath: /path/to/element
                replace_record_id_query: SELECT Id from Account WHERE name='Specific Account'
                api: rest
                

This example's for an embedded Account Id, but it should be workable for this scenario as well. A Tooling API query can be used to query for metadata.

3
  • Huh that's interesting. So in this case though if the report is packaged and it's referencing something org specific (a field unique id), is that still possible? Wouldn't the order of the operations mean you can't fix the metadata before it's deployed when deploying that metadata as part of package and not just raw metadata. I can understand how it would work for the scratch org deployment scenario but if the report is packaged up and being deployed to a persistent org. Feb 28 at 4:46
  • Oh jeez, I apologize, @JackMcGrady. I spaced the packaging angle in this answer. This will help only during deployments, not packaging. If you've essentially come up with a metadata structure that ought to support packaging but doesn't, please do raise a case and tell me the number so I can peek at it. (I'm not on that team and cannot take any action but would like to monitor).
    – David Reed
    Feb 28 at 22:56
  • Case #467398974 May 13 at 16:28

You must log in to answer this question.

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