About the PhotoShop OriginalDocumentID

Why do I get the XMPMetadataAsUTF8 via Batchplay when I create a new file,But the XML MetadataasutF8 that we get, we don


't have OriginalDocumentID …

For a document with no xmp yet, from a file new, Photoshop will fill in some defaults when it gets a request. Are you saying that the OriginalDocumentID is not part of the defaults and you need it? This should be the same behavior if you use the File Info dialog and look at the raw data tab.

I tried using Batchplay to modify the document I specified, but my XMP source file never changed

Please supply your script and XMP and I’ll see if I can figure out what is going wrong.

import { convert} from 'xmlbuilder2';

 function getDocumentXMPMeta(docId,xmpString){
    const res = await batchPlay([ {
    _obj: 'get',
    _target: [
      {
        _ref: 'document',
        _id: documentID,
        _property: 'XMPMetadataAsUTF8',
      },
    ],
    _options: {
      dialogOptions: 'dontDisplay',
    },
  }], {
  });
  return res[0]?.XMPMetadataAsUTF8 || '';
}

 function setDocumentXMPMeta(docId,xmpString){
    const res = await batchPlay([ {
    _obj: 'set',
    _target: [
      {
        _ref: 'document',
        _id: docId,
        _property: 'XMPMetadataAsUTF8',
      },
    ],
    to: {
      _obj: 'document',
      XMPMetadataAsUTF8: xmpString,
    },
  }], {
  });
  return res[0]?.XMPMetadataAsUTF8 || '';
}

function setMetaXmp(docId){
  const xmpString = await getDocumentXMPMeta(docId);
  const obj = convert(xmpString, { format: 'object' });
  obj['x:xmpmeta']['rdf:RDF']['rdf:Description'][`@xmlns:${123}`] = 'test1';
  obj['x:xmpmeta']['rdf:RDF']['rdf:Description'][`${'xml'}:${456}`] = 'test2';
  const newXmpString = convert(obj, { format: 'xml' });
  await setDocumentXMPMeta(docId, newXmpString);
  const newString = await getDocumentXMPMeta(docId);
  console.log('oldXml',xmpString) //old xmp 
  console.log('newXml',newString)   // new xmp
}

setMetaXmo(1); // execute

I’m transferring the XML:

But I got a new one:

this fails to modify xmp :sob: