- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 10:43 PM
Hello Experts,
We have a UI Action named "Escalate" once a fulfiller click on this field the incident is escalated to next level group. We have a field created referencing to user table named "L1 Escalated By" so who ever is clicking on this Escalate button his name must be populated in "L1 escalated by" field. If second time this is escalated to L2 level then the user name must populate in "L2 escalated by". Is this possible? If yes, how? and if No, then why?
Please advice and guide. Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 04:28 PM
function onSubmit() {
//Type appropriate comment here, and begin script below
var action = g_form.getActionName();
if (action == 'escalate') {
var user = g_user.getUserID();
var es1 = g_form.getValue('u_l1_escalated_by');
var es2 = g_form.getValue('u_l2_escalated_by');
var es3 = g_form.getValue('u_l3_escalated_by');
if (es1 == "") {
g_form.setValue('u_l1_escalated_by', user);
} else if (es1 != "" && es2 == "") {
g_form.setValue('u_l2_escalated_by', user);
} else if (es1 != "" && es2 != "" & es3 == "") {
g_form.setValue('u_l3_escalated_by', user);
}
}
}
Here this works!
Please mark my solutions helpful, Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 05:20 AM
Hi Zack,
I have added below code which is working fine for L1 escalation
function onSubmit() {
//Type appropriate comment here, and begin script below
var action = g_form.getActionName();
if(action == 'escalate')
g_form.setValue('u_l1_escalated_by', g_user.getUserID());
}
Please guide how can we add L2 and L3 escalation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:16 AM - edited 01-11-2024 06:18 AM
Hi @Ankita Gupte ,
Add below logic in your UI action for other escalations as well
var action = g_form.getActionName();
if(action == 'escalate')
if(g_form.getValue('u_l1_escalated_by') == ""){
g_form.setValue('u_l1_escalated_by', g_user.getUserID());
}
f(g_form.getValue('u_l1_escalated_by') != "" && g_form.getValue('u_l2_escalated_by') == "" ){
g_form.setValue('u_l2_escalated_by', g_user.getUserID());
}
if(g_form.getValue('u_l1_escalated_by') != "" && g_form.getValue('u_l2_escalated_by') != "" && g_form.getValue('u_l3_escalated_by') == "" ){
g_form.setValue('u_l3_escalated_by', g_user.getUserID());
}
}
Thanks,
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 04:28 PM
function onSubmit() {
//Type appropriate comment here, and begin script below
var action = g_form.getActionName();
if (action == 'escalate') {
var user = g_user.getUserID();
var es1 = g_form.getValue('u_l1_escalated_by');
var es2 = g_form.getValue('u_l2_escalated_by');
var es3 = g_form.getValue('u_l3_escalated_by');
if (es1 == "") {
g_form.setValue('u_l1_escalated_by', user);
} else if (es1 != "" && es2 == "") {
g_form.setValue('u_l2_escalated_by', user);
} else if (es1 != "" && es2 != "" & es3 == "") {
g_form.setValue('u_l3_escalated_by', user);
}
}
}
Here this works!
Please mark my solutions helpful, Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:33 AM
you can multiple if else statements
are you hiding the UI action once all Level escalation is done?
If yes then you should ensure UI action is shown with proper condition
Why are you using onSubmit client script? You can have this code in your UI action code itself
Condition: current.u_l1_escalated_by == '' || current.u_l2_escalated_by == '' || current.u_l3_escalated_by == ''
Client checkbox: True
Onclick: escalateCode()
Script:
function escalateCode(){
var user = g_user.userID;
if(g_form.getValue('u_l1_escalated_by'))
g_form.setValue('u_l1_escalated_by', user);
else if(g_form.getValue('u_l2_escalated_by'))
g_form.setValue('u_l2_escalated_by', user);
else if(g_form.getValue('u_l3_escalated_by'))
g_form.setValue('u_l3_escalated_by', user);
g_form.save();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 02:59 AM
UI Action has many conditions based on which escalate function works hence wanted to go with client script.