Hi,
I defined a custom action which returns a boolean. I would like to create a javascript method that calls the action and returns the result.
This javascript method will then be used as an 'Enable Rule' in the ribbon.
I'm not that great in JScript and fairly new to promises.
The problem is that I have 2 async operations that need to be 'awaited' and the result of the 2th should be returned as method result.
Imaging that this part of code is in a JScript method, and I would like this method to return the result of the 2th operation -> response.IsKiamoEnabled
I have no clue on how I could achieve this properly (except using XMLHttpRequest with async = false)
var isKiAMOEnabled = false;
// Use the request object to execute the function
Xrm.WebApi.online.execute(request).then(
function (result) {
if (result.ok) {
result.json().then(function (response)
{
console.log("pw_IsUserKIAMOEnabled returned " + response.IsKiamoEnabled)
return response.IsKiamoEnabled;
});
}
return tmpisKiAMOEnabled;
},
function (error) {
console.log(error.message);
return false;
}
);
return isKiAMOEnabled;
Any help would be greatly appreciated …
Regards,
Sven Peeters