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-07-2022 06:26 AM
Hi,
if you want unique users in each of those 3 variables then why not use advanced ref qualifier on all 3 variables so that whatever user is selected in 1 variable that user won't be shown in other 2 variables
Variable A:
javascript:'sys_idNOT IN' + current.variables.variableB + ',' + current.variables.variableC;
Variable B:
javascript:'sys_idNOT IN' + current.variables.variableA + ',' + current.variables.variableC;
Variable C:
javascript:'sys_idNOT IN' + current.variables.variableA + ',' + current.variables.variableB;
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-07-2022 06:31 AM
Hi Ankur,
In this case .. Variable A & B can b same, so info message will show under B and if A,B & C are same then it will show the error message.
Basically A=B is fine , but A=B=C is not fine.
And tried the above ..Its not working as well.. Maybe I am doing any mistake.
active=true^u_user_type=^EQ^javascript:'sys_idNOT IN' + current.variables.u_hiringmanager+ ',' + current.variables.u_department_head;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 08:11 PM
Hi,
your query is wrong in ref qualifier
please add correct condition for u_user_type
'active=true^sys_idNOT IN' + current.variables.u_hiringmanager+ ',' + current.variables.u_department_head;
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 02:48 AM
Thanks
Is there any possibilty to do it by Client scripts ?