Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cancel save based on the result of async operation (Example 2)
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Account) == "undefined") { MEA.Account = {} };
if (typeof (MEA.Account.AccountForm) == "undefined") { MEA.Account.AccountForm = {} };
MEA.Account.AccountForm = {
onLoad: function (executionContext) {
var formContext = executionContext.getFormContext();
formContext.data.entity.addOnSave(
(() => {
var asyncSaveValidation = (saveCtx) => {
return new Promise((resolve, reject) => {
saveCtx.getEventArgs().preventDefault();
reject("error");
});
};
return async (saveCtx) => {
try {
await asyncSaveValidation(saveCtx);
}
catch (error) {
console.log(error);
}
}
}
)());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment