- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:10 AM
Hi All,
I have created a new choice field called u_vip with choices as "vip" and "v-vip" on sys_user table. How do i write a script include and a client script on incident table to identify if the user is a VIP or V-vip or a normal user. If user is a vip then i would like to have the background colour red and purple for a v-vip user.
Any help on this is greatly appreciated.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 07:47 AM
Hi @Oliver Stammler ,
The client would prefer to have a single choice field rather than the checkbox. Thank you so much for the script. One last request is, i am trying to add a image inside this field however it seems not to be showing the single image.
this is the below image i see
I was expecting to achieve something like this with the colour red in the background
below is the modified code which i tried :
```
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('UserUtils'); // UserUtils is the script include name
ga.addParam('sysparm_name', 'getVIPStatus'); // getVIPStatus is the function in the script include that we're calling
ga.addParam('sysparm_caller', g_form.getValue('caller_id').toString()); // send caller sys_id to the script include
ga.getXML(VIPCallerParse);
// callback function for returning the result from the script include
function VIPCallerParse(response) {
var vipStatus = response.responseXML.documentElement.getAttribute("answer");
switch (vipStatus) {
case 'vip':
g_form.getElement("sys_display.incident.caller_id").style.backgroundImage = "url('6.png')", style.backgroundRepeat = "no-repeat", style.backgroundPosition = "98% 55%", style.paddingright = '20px', style.backgroundColor = 'aqua' ;
break;
case 'v-vip':
g_form.getElement("sys_display.incident.caller_id").style.backgroundColor = "green";
break;
default:
// do nothing
}
}
}```
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 08:37 AM
Hey,
to be honest - I have no idea how to add an image there. Never did that before.
Seems like it could be possible, please see this: https://www.servicenow.com/community/developer-forum/how-to-replace-vip-icon-in-servicenow/m-p/22236...
All I did before was adding a second VIP badge like the ootb one. Here is the instruction for this: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752116
Feel free to mark my first answer helpful/correct so that future users now they can find an answer in this thread.
Sorry again that I could not help you with your second question.
Thanks and best regards
Oli