Skip to main content
Inspiring
Aug 7, 2025 6:08 AM UTC
Question

XMPMetaObj.setStructField and appendArrayItem not working in InDesign UXP?

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!

 

 

2 replies

leo.r
Community Expert
Community Expert
Aug 7, 2025 11:12 AM UTC

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

Translate
Inspiring
Aug 7, 2025 1:16 PM UTC

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.

Translate