Created
September 20, 2022 21:52
-
-
Save melamriD365/d4825a945a8d831676baa656754a2b27 to your computer and use it in GitHub Desktop.
Sample usage of the OnOutputChange event for model-driven app forms Client API
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
var MEA = window.MEA || {}; | |
var accountForm = MEA.accountForm || {}; | |
(function () { | |
this.OnLoad = function (onLoadContext) { | |
var formContext = onLoadContext.getFormContext(); | |
var phoneControl = formContext.getControl('telephone1'); | |
phoneControl.addOnOutputChange(this.OnOutputChangeHandler); | |
}; | |
this.OnOutputChangeHandler = function (OnOutputChangeContext) { | |
let attribute = OnOutputChangeContext.getEventSource(); | |
let formContext = OnOutputChangeContext.getFormContext() | |
switch (attribute.getName()) { | |
case 'telephone1': | |
let telephone1Control = formContext.getControl('telephone1'); | |
let telephone1ControlOutput = telephone1Control.getOutputs(); | |
let isValidTelephone1 = telephone1ControlOutput["telephone1.fieldControl.isValid"].value | |
if(!isValidTelephone1){ | |
telephone1Control.setNotification('Telephone1 is not valid','telephone1ControlNotification'); | |
} | |
else { | |
telephone1Control.clearNotification('telephone1ControlNotification'); | |
} | |
console.log(this.isValid_telephone1); | |
break; | |
default: | |
break; | |
} | |
} | |
}).call(accountForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment