Created
June 1, 2021 08:34
-
-
Save melamriD365/5359e3276c433be7932cd30b234d8d25 to your computer and use it in GitHub Desktop.
Cancel save based on the result of async operation (Example 2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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