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
Tera Patron
Tera Patron

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

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

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;

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

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

Thanks @Ankur Bawiskar ,

Is there any possibilty to do it by Client scripts ?