0

I have an optionset field in an entity, I want to fire a JavaScript method on this field change. I want to capture the old value of the field on the change. I've got a solution which gets the old value on form load, but this doesn't work on multiple changes.

Arun Vinoth
  • 20,360
  • 14
  • 48
  • 135

1 Answers1

1

This has to be solved by our own code implementation. Store the attribute value on form load in a variable, keep the new value in that variable on every change, so you can use that in onChange handler. At the end of business validation inside handler put that new value in variable if success or revert to old value if failed.

var previousValue;

function onFormLoad(){
    previousValue = formContext.getAttribute("fieldname").getValue();
}

function onFieldChange(){
if(myBusinessValidationSucceeds){
    previousValue = formContext.getAttribute("fieldname").getValue();
}
}

Idea 1 and Idea 2

Arun Vinoth
  • 20,360
  • 14
  • 48
  • 135