Is it feasible to utilize Custom Properties in the JavaScript API 1.3 for Office?

I recently came across the MS Office JS API 1.3 documentation regarding custom properties, but I am facing difficulty in reading any custom property items from Word settings using Office JS.

       `Word.run(function (context) {

            // Create a proxy object for the document.
            var thisDocument = context.document;

            var customProperties = thisDocument.properties.customProperties;

            context.load(customProperties);

            return context.sync().then(function () {
                var getcount = customProperties.getCount();

                console.log(customProperties.items);
                return context.sync().then(function () {
                    console.log(getcount.value);
                });
            });
        })`

The customProperties.items always return an empty array, and I cannot seem to find the set method in customProperties. My custom property is visible in this (https://i.sstatic.net/AywDo.png).

Is it possible that the MS Office JS API does not currently support accessing custom properties in Word?

Answer №1

It seems like the issue may be related to your Office Client not being updated to version 16/0.7766+. I tested your code in a recent build and was able to retrieve the custom properties successfully. Make sure you are working on the latest update by following these instructions.

By the way, I simplified your code snippet. Hopefully, this clarifies things for you!

function fetchProperties() { 
    Word.run(function (context) {
        var customDocProps = context.document.properties.customProperties;
        context.load(customDocProps);
        return context.sync()
            .then(function () {
                console.log(customDocProps.items.length);
             })
     })
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Pressing the reset button will initiate once the loader has finished

Hello everyone, I'm currently working on creating a button that transforms into a loader when submitted and then reverts back to a button after the form is successfully submitted. I suspect the issue lies within my JavaScript. I'm not sure how ...

What's the best way to transfer a variable from a PHP file to a jQuery AJAX file so that it can be used as the URL parameter when sending

I am just starting out with javascript, jquery, and ajax. Unfortunately, I've encountered an issue where my code is not working as expected. Below, you can find a detailed description of my code and the problem at hand. If someone could offer some ass ...

What is the best way to store the result of a mongoose query in a global variable in Node.js?

I retrieved results from the Mongo database and saved them in a variable within a function. However, I am unable to access that variable outside of the function. How can I resolve this issue? Currently, I can see the results inside the function using the ...

What steps can be taken to convert a list box into an editable box?

I created a listbox using a table because I needed to display two columns for the list. Now, I am attempting to enable editing the text directly within the table when I select an item from the listbox. Essentially, I want the selected item to become an edi ...

What is the best way to handle dependencies within AngularJS code?

Hey there, I have a question about managing dependencies. Let's take a look at this example: MyApp.controller("MyController", ["$scope", "$document", "$timeout", "SomeService", function(scope, doc, timeout, service){ /*Some Code here*/ }]); The ...

Using JavaScript, capture the current date and time and store it in a .txt file with the corresponding format

Objective: Upon clicking the download link, an automatically named file will be downloaded with today's date and time format. For example, 7-3-2021 04:04:00 PM or any applicable format with the date and time included in the name. Below is the code sn ...

I just finished crafting a dynamic line chart with d3.js within a React environment. However, I am now looking to add some personalized touches to enhance its appearance. Could you kindly review the details and code

I want to create a line chart using React and D3, similar to the one depicted in this image. Presently, I have partially implemented the chart with the code provided below. You can see it here. The code snippet I've developed so far is outlined as f ...

Is getElementById() returning null?

I'm currently working on a JavaScript program that takes an image URL and displays it on the page by creating an <img> tag. This way, I can easily add multiple images to the page. Here is my code: <!DOCTYPE html> <html lang="en&quo ...

Looking to incorporate an array of objects with identical keys and multiple values in react.js?

My dilemma involves an array containing numerous objects with identical keys. I am seeking a way to merge these objects based on chapter name without sacrificing any other values. https://i.sstatic.net/1Jjs3.png I have experimented with various methods, ...

Creating a dynamic directive in AngularJS: Learn how to add or remove it from the DOM based on specific conditions

Suppose I have a customized modal directive that looks like this: return { restrict: 'E', templateUrl: 'modal.html', scope: { modalContent: "&", modalOpen: "&" } } And in the HTML: <ng-modal modal-content="co ...

What's the best way to incorporate mouseenter() and mouseleave() into several elements sharing the same class?

I have a vision for a fun game where players must navigate from one platform to another without falling off the edges. The game starts when you hover over the initial platform, and success is achieved by reaching the final platform. However, failure occurs ...

"Implement a 'Show More/Show Less' Button Functionality for Various Content Using

I'm having trouble implementing a JavaScript solution that adds read more/less buttons to my testimonials. The issue is that it only seems to work for one button and not multiple as I had hoped. Is there a way to modify this code so that it can be use ...

Troubleshooting the AutoHeight Problem in Slidesjs

My issue revolves around Slidesjs which can be found at . Specifically, I am facing a problem with autoHeight feature not displaying properly in Chrome. Initially, the height of slides shows as 0px but upon clicking to the next slide, it adjusts to the c ...

Stop unauthorized HTTP requests by limiting a web application to only communicate with specified domains

I have come up with an innovative security feature idea for browsers/web clients, but I have not been able to find any information or discussions about it. Therefore, I am seeking an answer to determine the feasibility and necessity of such a feature. Que ...

Issues with Javascript causing MongoDB batch insert to fail

I need assistance with optimizing my Javascript code. I have created a script to insert multiple records into a collection at once using "insertMany()". However, the code I wrote is not functioning correctly: var batch = []; for (i=0; i<10; i++) { ...

Using html and the javascript library 'turn.js' to make an interactive flipbook

I'm trying to use the turn.js library to create a flipbook. Here is the code I have been using, but it doesn't seem to be working correctly for me. It currently works fine on jsfiddle and you can see it here [text]http://jsfiddle.net/xd7sh59p/ W ...

Error encountered: The property indexOf cannot be read. Possible issue with .load() function in jQuery causing this error

https://i.sstatic.net/R7zUX.png As I navigate through the page and interact with different elements, I encounter an error message. The Obj function, which is responsible for setting a property value in an object from a handlebars template input and loadi ...

JavaScript onClick event not functioning properly on iOS devices

I have created a code that can detect when a user clicks on a cell in a table and retrieves the background color set for that cell. Everything works perfectly on my desktop computer, but when I attempt to use my iPad, it does not respond. I attempted to u ...

Is there a way to make the button text bold before deleting it post clicking on an alert message?

While testing my sequence in IE, I noticed that it appeared correctly, but in Chrome, the button text was not showing up as bold. Instead, only the alert message was displayed, and the button itself was removed. Upon further investigation using Chrome&apo ...

Combine all the HTML, JavaScript, and CSS files into a single index.html file

So here's the situation - I am utilizing a C# console application to convert four XML files into an HTML document. This particular document will be circulated among a specific group of individuals and is not intended to be hosted or used as a web app; ...