+ Start a Discussion
Tom Coffey 4Tom Coffey 4 

Deployment error: "invalid cross reference id" / How do I determine which Profiles are referenced in .app metadata files?

I’m attempting to migrate metadata from one org to another using a package.  But my deployment keeps failing with “Error  test/applications/Underwriting.app  Underwriting  invalid cross reference id”

Originally I was all three .app files in my metadata package were failing.  Then I did something (IDK what – I tried a bunch of stuff) that got two of the .app files to deploy and only one is failing now.

Looking at what changed in the .app files that failed but now deploy without error, I notice they no longer contain references to many standard profiles.  They only reference custom profiles and the Admin profile.  No other standard profiles besides Admin.

Also, if I look at the .app files that continues to cause problems, I see that it contains references to many if not all of the standard profiles.  As a result, I suspect it is the inclusion of these standard profiles that is causing problems.

I thought the fix would be easy: go to Setup > App Manager > App Settings > User Profiles, move the standard profiles from the Selected Profiles column to the Available profiles column and then update the package.

The problem is that it does not seem that changes I make to App Manager > App Settings > User Profiles are reflected in the .app metadata files in my package.

Removing standard profiles from the app with the .app file producing the error does not remove them from the .app metadata file.  Similarly, adding standard profiles to the apps whose .app files do not contain standard profiles does not add the selected standard profiles to these .app files.

This has left me perplexed.  Is the issue the standard profiles in the .app file?  If not App Manager > App Settings > User Profiles, how do I control which profiles appear in my .app files? 

Note: I’ve searched for similar errors / possible solutions.  The first link below sounds most similar but it’s marked as a “fixed” known issue as of a year ago so I don’t think that’s the issue.  The second link says there’s an invalid record ID in my code.  But the error messages I get identify the files producing the error and I’m 100% positive they do not contain any record (or other IDs).

https://success.salesforce.com/issues_view?id=a1p3A000000mCIdQAM&title=invalid-cross-reference-id-deploying-custom-app-with-profileactionoverrides-referencing-new-profiles-in-same-deployment (https://success.salesforce.com/issues_view?id=a1p3A000000mCIdQAM&title=invalid-cross-reference-id-deploying-custom-app-with-profileactionoverrides-referencing-new-profiles-in-same-deployment" style="color:blue; text-decoration:underline)

https://developer.salesforce.com/forums/?id=906F0000000BIhXIAW (https://developer.salesforce.com/forums/?id=906F0000000BIhXIAW" style="color:blue; text-decoration:underline)
 
Richard Wang 182Richard Wang 182
Hi Tom, 
It is a late reply but it may be helpful for people who may encounter the same issue in the future.
Root Cause: If the CustomApplication has "ProfileActionOverrides", it tries to get profileId from the target instance when deploying.
But if the profile is not available in the target SF instance, it will throw an "invalid cross reference id" error.

Solution: Any of the solutions would work.
1) Find the missing Profile in the target instance. Create the Profile before the deployment.
2) Remove the Profile related data block from CustomApplication Metadata File.
Note: "Call Centre' is the Profile Name.
 <profileActionOverrides>
        <actionName>View</actionName>
        <content>Call_Centre_Lead_Lightning_Record_Page</content>
        <formFactor>Large</formFactor>
        <pageOrSobjectType>Lead</pageOrSobjectType>
        <recordType>Lead.Referred_Lead</recordType>
        <type>Flexipage</type>
        <profile>Call Centre</profile>
    </profileActionOverrides>
2) Do not deploy CustomApplication. Add them in the target instance after deployment.

Cheers!
Richard
 
Gary WGary W
I'm also experiencing this issue. All of the profiles in my source org exist in my target org though, and they are also all included in the change set. I believe the issue in my case is due to this known issue: Special Characters like '+' when included in Name of a profile being deployed in an App can cause 'invalid cross-reference id' error (https://trailblazer.salesforce.com/issues_view?id=a1p3A000000mCnsQAE). We have a few profiles with + characters in them.

I have tried to manually remove the <profileActionOverrides> blocks which reference the affected profiles, from in the app metadata, however this isn't working as expected. When I deploy the modified metadata using SFDX, then retrieve the source form the org again, the changes have been reverted, and the removed blocks are again present with the problematic profile names.