customXmlParts.getByNamespaceAsync is not working for PowerPoint

Razic Armin 0 Reputation points
2023-04-27T12:34:48.09+00:00
I have implemented this code to get document Id using, but it is not working for PowerPoint


function getDocumentID() {
        const XML_NS = 'http://schemas.microsoft.com/office/2006/metadata/properties'
        Office.context.document.customXmlParts.getByNamespaceAsync(XML_NS, (result) => {
            if (result.status !== Office.AsyncResultStatus.Succeeded) return
            const part = result.value[0]
            part.getNodesAsync('*/documentManagement/*', (result) => {
                if (result.status !== Office.AsyncResultStatus.Succeeded) return
                result.value.forEach((node) => {
                    if (node.baseName === "_dlc_DocId") {
                        node.getXmlAsync(result => {
                            if (result.status === Office.AsyncResultStatus.Succeeded) {
                                var res = result.value;
                                documentID = res.substring(res.lastIndexOf('">') + 2, res.lastIndexOf("</"));
                                console.log(documentID);

                            } else {
                                console.error('failed to set node text', result.error)
                                showNotification("Error:", e);
                            }
                        })
                    }
                })
            })
        })
    }
PowerPoint
PowerPoint
A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
247 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,687 questions
0 comments No comments
{count} votes