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 - My requirement is out the 3 varibales , any two values can be same , but if 3 values will be same then it will show the alert/not allow to submit. 

Onsubmit client script is not allowing to sbmit when any two values are same.

 

Hope you understand and thanks for your patient.

Hi,

then it should work fine

Can you share what came in alert for that array? does it contain unique sysIds?

Regards
Ankur

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

@Ankur Bawiskar - are you asking about this ?

find_real_file.png

Hi,

not that

the script is pushing the 3 values one by one to array

so did you check what value came in that array by alerting that?

alert(arr);

Regards
Ankur

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

@Ankur Bawiskar -  I choosed 2 same values & one different values, the below sys_id returns,

find_real_file.png