VIP flag is not working in REQ/RITM/SC Task forms Requested For field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2022 10:18 PM - edited 12-19-2022 03:11 AM
Hi All,
VIP flag is not visible in REQ/RITM/SC Task forms Requested For field.
I can see it as an OOB feature for only incident caller filed,
but I have to enable it for REQ/RITM/SC Task forms
Can someone suggest me the logic or approach
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 05:04 AM
The answer is given here:
https://www.servicenow.com/community/now-platform-forum/vip-incidents-and-requests/m-p/1075054
This will show you how to add it for the REQ (sc_request) table, then do the same for the RITM (sc_req_item) and SCTASK(sc_task) tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 07:51 AM
Hi Brad,
Thank you for your reference
I have tried this OOB incident onChange client script logic working only for sc_request table and not working for RITM / SC Tasks because requested_for filed dot walked into the sc_req_item and sc_task tables
have you tried the same logic in sc_req_item and sc_task tables from your end
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:18 AM
Since you are displaying the Requested_for field from the Request table on the RITM and SCTASK table you will need to make a couple of changes.
Client Script for sc_req_item table:
function onLoad() {
var callerLabel = $('label.sc_req_item.request.requested_for');
var callerField = $('sys_display.sc_req_item.request.requested_for');
if (!callerLabel || !callerField)
return;
var number = g_form.getValue('number');
var ga = new GlideAjax("isVIP");
ga.addParam("sysparm_name", "vip");
ga.addParam("sysparm_numnber", number);
ga.getXML(vipCallBack);
}
function vipCallBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var callerLabel = $('label.sc_req_item.request.requested_for').down('label');
var callerField = $('sys_display.sc_req_item.request.requested_for');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (answer == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
//set callerField color
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
This is assuming your Form Layout shows Request.Requested for as a selected field
Then you will need to create a Script Include with the Client callable box checked:
var isVIP = Class.create();
isVIP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
vip: function(){
var number = this.getParameter('sysparm_numnber');
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", number);
gr.query();
if (gr.next()) {
return gr.request.requested_for.vip.toString();
}
},
type: 'isVIP'
});
This is the Client Script for the sc_task table:
function onLoad() {
//Type appropriate comment here, and begin script below
var callerLabel = $('label.sc_task.request_item.request.requested_for');
var callerField = $('sys_display.sc_task.request_item.request.requested_for');
if (!callerLabel || !callerField)
return;
var number = g_form.getValue('request_item');
var ga = new GlideAjax("isVip");
ga.addParam("sysparm_name", "vip_sctask");
ga.addParam("sysparm_numnber", number);
ga.getXML(vipCallBack);
}
function vipCallBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var callerLabel = $('label.sc_task.request_item.request.requested_for').down('label');
var callerField = $('sys_display.sc_task.request_item.request.requested_for');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (answer == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
//set callerField color
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
Assuming the SCTASK form Layout shows Request Item.Request.Requested for as a selected field
Then, to show the icon on the RITM and SCTASK table list views, assuming the list layout of each contains Request.Requested for, all you need to do is change the Value of the Style that you created to show the icon on the sc_request table, and it will show on all 3 tables!
javascript:current.requested_for.vip==true||current.request.requested_for.vip==true;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:52 AM
Hi Brad,
Thank you for your help, I can see VIP flag on native Incident / RITM / ScTASK form but I can't see it on the Agent workspace, client wants to show this Icon in the Agent Workspace, do we have feasibility?
Thanks