How to show Field Info message & Field error message on some condition ?

ads
Tera Expert

Hi All,

I have 3 varibales suppose A, B, C refering to the user table, If A=B, then it will show a field info message under the B field. If A=B=C, then it will show error message under the C field and clear the value of C as well.

I have tried the below , but its not working.


if (g_form.getValue('field_name') == g_form.getValue('field_name')) {
g_form.showFieldMsg('field_name', 'It cannot be the same person.', 'info', true);
}

else if ((g_form.getValue('field_name') == g_form.getValue('field_name')) &&(g_form.getValue('field_name') == g_form.getValue('field_name'))) {

g_form.clearValue('field_name');
g_form.showErrorBox('u_regional_director', 'Please note that the Hiring manager, Department head and Regional director cannot be the same person.', 'error');
}
}

 

@Ankur Bawiskar 

22 REPLIES 22

@Ankur Bawiskar ,

Still Its not working. Its allowing to submit when all the 3 varibale values are same .

Hi,

what debugging did you perform from your side?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

I have tried to write 3 Onchange client scripts for each varibales by putting alternate if conditions, Its working , But dont no with other scenarios . Still I am testing on this.

And for the above script provided by you,I think Its not getting the value from the varibales , so its unable to show the alert as well.