show vip tag on ritm form requested for in servicneow
- User
show vip tag on ritm form requested for in servicneow
- Assistant
- User
how to do this as incident vip shown
- Assistant
show vip tag on ritm form requested for in servicneow
how to do this as incident vip shown
To display a VIP tag on the Requested Item (RITM) form in ServiceNow, you typically need to customize the form layout, add client scripts, or business rules to display this information dynamically. Here's a step-by-step guide on how you might achieve this:
Identify the VIP Status Field:
Ensure that you have a field in the user profile to mark a user as VIP. This is typically a boolean field, e.g., vip or u_vip.
Modify the RITM Form Layout: Add a field to the Requested Item form to display the VIP status:
Incident -> Open (or the equivalent menu where you can open an incident).Configure > Form Layout.VIP Status) to the form layout.Create a Client Script:
Write a client script to check the vip status of the requested_for user (the user who requested the item) and display a tag/icon.
// Client Script
(function executeRule(current, previous /*null when async*/) {
// If the user is a VIP, show the VIP tag
if (current.requested_for.vip) {
g_form.addInfoMessage("🚀 VIP User");
}
})(current, previous);
Or if you want a more visual approach with a custom field:
// Client Script
(function executeRule() {
// Fetch details of the 'requested_for' user
var userId = g_form.getValue('requested_for');
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
if (userGR.vip) {
g_form.setValue('u_vip_status', '🚀 VIP User');
g_form.setDisplay('u_vip_status', true); // Ensure field is visible
} else {
g_form.setDisplay('u_vip_status', false); // Hide if not VIP
}
}
})();
Requested Items -> All (or similar).Configure -> Client Scripts.onChange / onLoad.Create a Business Rule (Optional): If you need to set the VIP status based on another condition or update the status on certain operations such as the creation or update, write a business rule.
// Business Rule
(function executeRule(current, previous /*null when async*/) {
var userId = current.requested_for;
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
if (userGR.vip) {
current.u_vip_status = '🚀 VIP User';
} else {
current.u_vip_status = '';
}
}
})(current, previous);
System Definition -> Business Rules.Keep in mind that the exact implementation might vary based on your instance’s customizations and field names. Adjust the field references (vip, u_vip_status, etc.) according to your instance's configurations.
To show a VIP tag or indicator on the Incident form in ServiceNow, you can follow a similar process to the one described for the Requested Item (RITM) form. Below are the details on how to achieve this:
Check VIP Field on User Profile:
Ensure that the VIP field exists on the sys_user table. Usually, this field is a boolean (true/false) value, often named vip or something similar.
Add VIP Indicator to Incident Form Layout:
Incident -> All or Incident -> Open in the left navigation panel.Configure -> Form Layout.u_vip_status.Create a Client Script:
This client script will check the vip status of the caller_id (the user who reported the incident) and display a VIP tag.
System Definition -> Client Scripts.New to create a new client script and use the following configuration:// Client Script Configuration
Type: onChange / onLoad (decide based on requirements)
Table: Incident
// Script for onLoad
(function() {
var callerId = g_form.getValue('caller_id');
if (callerId) {
// Retrieve caller to see if they are VIP
var userGR = new GlideRecord('sys_user');
if (userGR.get(callerId) && userGR.vip == true) {
g_form.addInfoMessage("🚀 VIP User");
}
}
})();
// Script for onChange
(function() {
if (typeof g_form === 'undefined') { // Ensure g_form is defined
return;
}
var callerId = g_form.getValue('caller_id');
if (callerId) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(callerId) && userGR.vip == true) {
g_form.addInfoMessage("🚀 VIP User");
} else {
g_form.clearMessages();
}
}
})();
Here, you might want the script to run onLoad and another script to run onChange of the caller_id field.
Update a Form Field Based on VIP Status:
If you prefer to show a custom message or tag within a form field:
u_vip_status (String type).// Client Script Configuration
Type: onLoad / onChange (both required)
Table: Incident
// onLoad script
(function() {
displayVipTag();
})();
// onChange script
(function() {
displayVipTag();
})();
function displayVipTag() {
var callerId = g_form.getValue('caller_id');
if (callerId) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(callerId) && userGR.vip == true) {
g_form.setValue('u_vip_status', '🚀 VIP User');
g_form.setDisplay('u_vip_status', true);
} else {
g_form.setDisplay('u_vip_status', false);
}
}
}
Testing:
Caller field to a user marked as VIP and observe the VIP tag displaying appropriately.To automatically set a u_vip_status field on the Incident table based on the caller_id's VIP status when the record is inserted or updated, you can follow this additional step.
System Definition -> Business Rules.New and configure it as follows:// Business Rule Configuration
Name: Set VIP Status
Table: Incident
When: before
Insert: true
Update: true
// Business Rule Script
(function executeRule(current, previous /*null when async*/) {
var userGR = new GlideRecord('sys_user');
if (current.caller_id && userGR.get(current.caller_id)) {
if (userGR.vip == true) {
current.u_vip_status = '🚀 VIP User';
} else {
current.u_vip_status = '';
}
}
})(current, previous);
By setting up and aligning these mechanisms, you can ensure that the VIP status is correctly indicated in your Incident management forms in ServiceNow.
Not yet included in a published release.