- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 09:21 AM
Hello everyone,
I have a requirement to display VIP flag for 'Requested for' for Request. This flag should be displayed on REQ, RITM and SCTASK form.
I referred to the below community and created client script on REQ and RITM and Script include, but i see the flag only on REQ form and not on RITM and SCTASK form.
https://community.servicenow.com/community?id=community_question&sys_id=7700a12fdb32afc011762183ca9619f4
Looking for any help on this.
Below are the scripts.
Client script on sc_request table :-
function onLoad() {
var callerLabel = $('label.sc_request.requested_for');
var callerField = $('sys_display.sc_request.requested_for');
if (!callerLabel || !callerField)
return;
g_form.getReference('requested_for', vipCallerCallbackREQ);
}
function vipCallerCallbackREQ(caller) {
var callerLabel = $('label.sc_request.requested_for').down('label');
var callerField = $('sys_display.sc_request.requested_for');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (caller.vip == '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: ""
});
}
}
Client Script on sc_req_item table :-
function onLoad() {
//Type appropriate comment here, and begin script below
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: ""});
}
}
Script Include :- (Client callable checked in)
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;
}
},
type: 'isVIP'
});
Solved! Go to Solution.
- 5,320 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2020 04:48 AM
I'm glad to hear that you are now able to view the icon on the 3 forms.
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
‎04-25-2022 06:00 AM
Hi Geetika,
Thanks for your response. Much appreciated!!!
Now VIP flag is displaying before Requested for in Request & Requested Item form however the text color is still black and doesn't change to red.
Any idea what is wrong & why it is changing even the alert is reaching out there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2023 08:35 PM
Hi @gs7
Thank you so much for sharing the scripts. Does it mean the three client scripts in REQ, RITM and SCTASK (without the script in the Script Includes) do not accomplish to display and colour the VIP in REQ, RITM and SCTASK? As I haven't worked on the Script Includes before, I do not really know what it does for (as my scripting knowledge is very limited). When I set up VIP in Incidents, I didn't have to use that. That's why I am just wondering if you can share your knowledge.
Thank you in advance.
Regards
mmk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2024 08:24 AM
please explain how I am supposed to code the sc_task client script. Its the only vip flag not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 06:25 AM
Hi @Brad Bowman ,
Added the code as suggested but VIP flag appearing in form view but not appearing in the List view. Could you please help me to fix it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 06:50 AM
You don't want to change the Reference qualifier, rather create or edit a Style record (left nav System UI > Field Styles)