correct me that javascript is wrong

venkyc
Kilo Contributor

@RakeshDarshnala 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === oldValue) {
        return;
    }

if (newValue === 'Closed') {
  g_form.showFieldMsg('state','Cannot close directly. Please follow the proper workflow.' );
  g_form.setValue('state', oldValue);
}
1 REPLY 1

SohamTipnis
Tera Guru

Hi @venkyc,

 

There is 1 issue I found out: in the loop of if, where you have used 'Closed,' you should use 7, as 'Closed's backend name is 7. That is the issue you are facing.

 

Let me know if this works. 👍

If you find my answer useful, please mark it as Helpful and Correct 😊

 

Regards,

Soham Tipnis

ServiceNow Developer ||  Technical Consultant

LinkedIn: www.linkedin.com/in/sohamtipnis10