Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Created September 20, 2022 21:52
Show Gist options
  • Save melamriD365/d4825a945a8d831676baa656754a2b27 to your computer and use it in GitHub Desktop.
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
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