As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
I need to parse that XML to add metadata to the document via javascript. I just cannot find a way to extract the value from that XML. Any idea would be welcomed.
Thanks.
Pablo
From Repository JavaScript API, this should work:
var docXml = new XML(document.content);
Thanks Angel,
I got that far and it works but my problem is retrieving a value within the XML.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><DocumentSet> <Document> <FileName>Brief - Lettre_4umqrm82l5ay.pdf</FileName> <FilePath>\\alfresco\alfresco\MailRoom\Brief - Lettre_4umqrm82l5ay.pdf</FilePath> <Confidentiality>3-Organisation</Confidentiality> <Departement>CUAC</Departement> <Domein___Domaine>DC</Domein___Domaine> <Info_type>Brief - Lettre</Info_type> <Medewerker___Collaborateur>Alain Terrieur</Medewerker___Collaborateur> <Status___Statut>5 - Overgedragen - Transféré</Status___Statut> </Document></DocumentSet>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DocumentSet> <Document> <FileName>Brief - Lettre_4umqrm82l5ay.pdf</FileName> <FilePath>\\alfresco\alfresco\MailRoom\Brief - Lettre_4umqrm82l5ay.pdf</FilePath> <Confidentiality>3-Organisation</Confidentiality> <Departement>CUAC</Departement> <Domein___Domaine>DC</Domein___Domaine> <Info_type>Brief - Lettre</Info_type> <Medewerker___Collaborateur>Alain Terrieur</Medewerker___Collaborateur> <Status___Statut>5 - Overgedragen - Transféré</Status___Statut> </Document>
</DocumentSet>
I just can't seem to get the <Info_type> Value!
Frustrating!
This should work:
docXml.DocumentSet.Document.Info_type
Angel, That is what I thought also but ... no luck!
This is taken to its most basic, following your advice and documentation!
var docXml = new XML(document.content);var infoType = docXml.DocumentSet.Document.Info_type;document.properties.title = infoType;document.save();
Drowing in frustration!
Thanks for your help!
This works...
var docString = document.content; if (docString.startsWith("<?xml")) { docString = docString.split("\n").slice(1).join("\n") } var docXml = new XML(docString); var infoType = docXml.DocumentSet.Document.Info_type; logger.log(docXml.Document.Info_type);
... you can change / improve it, as it's a quick PoC.
Thanks Angel but I have no results. I even tried to change the name of the document but nothing. It is as if the variable was not populated.
I will give it a shot tomorrow on another Alfresco instance in the office and follow your proposition. I’ll let you know the results.
I really appreciate your time and help.
It looks like I included a bad sample.
IMO, the main problem is that you have to omit "DocumentSet" when recovering values from XML.
This doesn't work...
docXml.DocumentSet.Document.Info_type
... but this works
docXml.Document.Info_type
Thanks Angel, It works!
Big thanks for your help!