- 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,341 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
‎01-22-2025 07:29 AM - edited ‎01-22-2025 07:41 AM
Hi @Brad Bowman , Thank you so much for your quick response and the issue was fixed.
While doing testing I impersonated to two id's. These two id's are part of same group. Issue is Flag appearing List view for one user id not for another user id.
I verified of roles of both users and the person who is not able to see Flag has same roles with the person who is able to see flag+ additional roles but he is not able to see flag in List view. could you please help guide me to fix it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 09:41 AM
Are the two users looking at the same list view, or does one have the columns personalized? Can this user see the incident VIP flag, or whatever other field styles you are using in your environment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 12:14 AM
Thanks for your inputs @Brad Bowman as you said he is created personal view and i did change now.
Able to see VIP flag for both Incidents and RITM's.