I have a CustomFunctions javascript that does work perfectly with sync functions but as soon as i try using Async function i get: "
Unhandled exception at line 21, column 707859 in https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js 0x800a139e - Der opstod en JavaScript-kørselsfejl: unexpected message type
" This happens before any javascript code is called on my js file. the message type is 1002 so ofcourse the error will be thrown given the javascript at the indicated place in the excel-win-16.01.js: "
if(i[t].messageType===1001)u.push(i[t]);else throw OfficeExtension.Utility.createRuntimeError(st.generalException,"unexpected message type", "
the json description for the function is:
{
"name": "helloasync",
"description": "simple test string return",
"helpUrl": "https://www.konsolidator.com",
"result": {
"type": "string",
"dimensionality": "scalar"
},
"parameters": [],
"options": {"sync": false}
},
{
"name": "ADD42ASYNC",
"description": "asynchronously wait 250ms, then add 42",
"helpUrl": "http://dev.office.com",
"result": {
"type": "number",
"dimensionality": "scalar"
},
"parameters": [
{
"name": "num",
"description": "Number",
"type": "number",
"dimensionality": "scalar"
}
],
"options": {
"sync": false
}
}
JS Code:
function helloasync() {
return new OfficeExtension.Promise(function (setResult) {
setTimeout(function () {
setResult("hello");
}, 1000);
});
}
function ADD42ASYNC(num) {
// waits 1 second before returning the result
return new OfficeExtension.Promise(function (resolve,reject) {
//resolve(num);
//reject(num);
setTimeout(function () {
resolve(num + 42);
}, 1000);
});
}
all of my async customfunctions fail! sidebar async functions works as expected as well as synchronous functions.