Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Last active June 1, 2021 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melamriD365/d414fc3552fbbc344d65af92f4774e35 to your computer and use it in GitHub Desktop.
Save melamriD365/d414fc3552fbbc344d65af92f4774e35 to your computer and use it in GitHub Desktop.
Cancel save based on the result of async operation (Example 1)
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) => {
//timeout 10 sec
//reject("error");
});
};
return async (saveCtx) => {
saveCtx.getEventArgs().preventDefaultOnError();
let result = await asyncSaveValidation(saveCtx);
}
}
)());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment