How to show Field Info message & Field error message on some condition ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 06:06 AM
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');
}
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 05:00 AM
Still Its not working. Its allowing to submit when all the 3 varibale values are same .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 08:06 AM
Hi,
what debugging did you perform from your side?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 10:46 PM
Hi
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.