Skip to main content

Resolving validation errors - "Field must be set for the Image constant"

Cause and solution to this Salesforce validation error related to deploying changes to "conversationMessageDefinition" metadata type

Written by Valerio Chang

Explanation of the error

When deploying conversationMessageDefinitions, the deployment fails because Salesforce cannot locate the image referenced in the metadata.

The error typically occurs because the image referenced in the metadata uses a file asset URL that differs between environments.

Example scenario:

  • Two environments contain the same image file

  • The image name appears identical

  • However, the file asset URL generated by Salesforce is different

Because the metadata references the URL, not just the filename, Salesforce cannot resolve the image during deployment.​


​

Why this happens

When files are uploaded into the Salesforce Asset Library, Salesforce may automatically rename the underlying file asset.

Even if the visible image name matches between environments, the generated asset URL may differ.

Since conversationMessageDefinitions reference the file asset URL, deployments will fail if:

  • The asset URL in the source org

  • Does not match the asset URL in the target org.


Resolution

Ensure the image asset exists in the target org and that the asset name/API name matches the one referenced in the metadata.
​
During upload, Salesforce allows you to modify the API Name, which must match the asset reference used by the messaging component.
​
To locate the image asset used by the conversationMessageDefinition.

  • Compare the asset file name and URL in both the source org and the target org.

  • If the asset URL differs between environments, update the metadata so the file reference matches the asset URL in the destination org.

  • In some cases, this can be resolved by retrieving the contentMessageDefinitions and updating the file asset reference to match the destination environment.

Disclaimer: This error is returned directly by Salesforce, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.

Did this answer your question?