Skip to main content
Inspiring
August 7, 2025
Question

XMPMetaObj.setStructField and appendArrayItem not working in InDesign UXP?

  • August 7, 2025
  • 1 reply
  • 253 views

Hii all,

I’m trying to add structured and array metadata in InDesign UXP using the new XMPMeta class, but I’m running into issues.

I have also registered the namespace, but setStructField() and appendArrayItem() do not work.

const doc = app.activeDocument;
const namespaceUri = "http://test.com/ns/";

const xmp = new XMPMeta(doc.metadataPreferences.rawXMP || "");

xmp.setStructField(
namespaceUri,
"testKey",
namespaceUri,
"testName",
"testValue"
);

Example to append an array item
xmp.appendArrayItem(
namespaceUri,
"TestArray",
"ArrayItemValue"
);

doc.metadataPreferences.rawXMP = xmp.serialize();

According to the documentation:
XMPMetaObj.setStructField(schemaNS, structName, fieldNS, fieldName, fieldValue[, options])
XMPMetaObj.appendArrayItem(schemaNS, arrayName, itemValue[, itemOptions, arrayOptions])


But the metadata does not appear in Raw Data or the metadata panel.

My questions:
1. setStructField() or appendArrayItem() not fully supported in InDesign UXP yet?
2. Is there a known bug or limitation with writing structured/array metadata this way?

3. What is the recommended or working way to add custom structured XMP metadata in UXP?

4. I hope I explained it clearly. Is there any solution to make this work in UXP?
Thanks!

 

 

1 reply

leo.r
Community Expert
Community Expert
August 7, 2025

I can only repeat my question from your previous thread: 

 

Are you sure you're not running into the very same issue discussed in your initial post here:

https://forums.creativeclouddeveloper.com/t/is-there-any-manifest-permission-for-activedocument-file...

 

That is, that you're still trying to modify an open document using an external library?

 

(Original thread: https://community.adobe.com/t5/indesign-discussions/uxp-scripting-solution-for-importing-and-exporting-xmp-metadata/m-p/15443854#M632709)

 

Also, can you point to documentation where you found the rawXMP property used in your script:

doc.metadataPreferences.rawXMP

Inspiring
August 7, 2025

Hi leo.r,

No, this is a different issue. I’ve already solved the original document permission problem discussed here:
https://forums.creativeclouddeveloper.com/t/is-there-any-manifest-permission-for-activedocument-filepath-in-indesign-uxp/11241/3


and in the original thread:

(Original thread: https://community.adobe.com/t5/indesign-discussions/uxp-scripting-solution-for-importing-and-exporting-xmp-metadata/m-p/15443854#M632709)

 

So this issue is unrelated.

Currently, my only concern is using setStructField and appendArrayItem to update XMP metadata.
I’m looking for a working code example that shows how to use these methods properly in a UXP plugin for InDesign.