Reputation: 5069
I want to try execute this function for Office API for JavaScript:
public loadCustomProperties() {
Excel.run(async (ctx) => {
let custom = ctx.workbook.properties.custom;
custom.load();
return ctx.sync();
})
}
But I got an error ERROR Error: Uncaught (in promise): GeneralException: An internal error occurred...
(nothing specific)
When I'm trying to load properties
instead of properties.custom
everything works fine.
Please help :)
EDIT:
This is the error I get:
ERROR Error: Uncaught (in promise): GeneralException: An internal error occurred while processing the request. RichApi.Error: An internal error occurred while processing the request. at new r (excel-web-16.00.js:21) at t.c.processRequestExecutorResponseMessage (excel-web-16.00.js:21) at excel-web-16.00.js:21 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:3760) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3751) at new r (excel-web-16.00.js:21) at t.c.processRequestExecutorResponseMessage (excel-web-16.00.js:21) at excel-web-16.00.js:21 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:3760) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3751) at resolvePromise (zone.js:814) at zone.js:724 at rejected (main.js:103) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:3760) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:3751)
EDIT 2:
I found this is a known bug: https://github.com/OfficeDev/office-js/issues/179
Upvotes: 0
Views: 336
Reputation: 5069
I've came up with this workaround method to load items. It turns out that if you ensure that count is greater than 0, you can safely load customProperties.
async function loadCustomPropertiess() {
await Excel.run(async (context) => {
var customProperty = context.workbook.properties.custom;
var customPropertyCount = customProperty.getCount();
await context.sync();
if (customPropertyCount.value > 0) {
customProperty.load();
await context.sync();
customProperty.items.forEach(prop => console.log(prop));
} else {
console.log("No custom properties");
}
});
}
Upvotes: 0
Reputation: 5036
modified code with 3 changes.
and I added a console.log just to verify that properties were loaded and they are.
async function loadCustomProperties() {
await Excel.run(async (ctx) => {
let custom = ctx.workbook.properties.custom;
custom.load();
await ctx.sync();
console.log(custom);
})
}
Upvotes: 1