-
-
Save furkankaracan/2a88775525b10a015b4732883632de13 to your computer and use it in GitHub Desktop.
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
function OnLoad(executionContext){ | |
var formContext = executionContext.getFormContext(); | |
//Register custom event | |
formContext.data.entity.addOnSave(validateOpportunityScore); | |
} | |
function validateOpportunityScoreOnSave(executionContext) { | |
var formContext = executionContext.getFormContext(); | |
var opportunityScore = formContext.getAttribute("new_opportunityscore").getValue(); | |
if (opportunityScore < 0 || opportunityScore > 100) { | |
formContext.getControl("new_opportunityscore").setNotification("Opportunity score must be between 0 and 100."); | |
//Prevent save | |
executionContext.getEventArgs().preventDefault(); | |
} else { | |
formContext.getControl("new_opportunityscore").clearNotification(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment