I am using custom property in the outlook add-in. I had saved some custom property. Now, I'm retrieving it in a local variable. While I'm retrieving the custom property at that time it's showing undefined. I had pasted the code. I want to store custom property in some variable that's why I tried to store it in the test variable. But it's not going to store the values in the test varible. My functions get executed after printing console. I didn't know where I had done a mistake.
can anyone guide me on this problem?
const mailbox = Office.context.mailbox.item;
const test = mailbox.loadCustomPropertiesAsync(function (result) {
const customProps = result.value;
const property = customProps.get("CustomMeeting");
return property;
})
console.log('Custom property', test)
In your code custom property is getting printed before the async call finishes. To ensure that call has completed, you can do the following:
let cp;
const mailbox = Office.context.mailbox.item;
mailbox.loadCustomPropertiesAsync(lcpCallback);
function lcpCallback(result) {
if (result.status != Office.AsyncResultStatus.Failed) {
cp = result.value;
console.log('Custom property:'+ JSON.stringify(cp));
}}