How to edit the 'On-Call Roster and Escalation details' modal, linked from the Incident form
Our organization had wanted to edit the On-Call Roster and Escalation details modal (called from the Incident form), to include another field, for pager number. We had already added two new fields to the user table: u_pager & u_pager_provider, but really you could include any extra details using this method.
Here is the example showing the new field, below the phone number and above the email.
This was tough as there were like 10 things in a chain that make this possible, but really only 3 (or 4) things needed updating. Also we noticed some strong caching of the SI, so when testing, use an incognito window and log out and back to see changes.
Solution:
1) Get the data ready by editing the source Script Include
The data that lands in the modal is generated via a method in the script include: OCEscalationPathUtilSNC
This is stock, so you cannot edit, but you can copy it by exporting the XML, changing the name and removing the sys_id, and re-importing. Our new SI is called OCEscalationPathUtilSTU.
Once imported, go to the function _getEscalationStepUsers, and see how the user object var is created with GlideUser.getUserByID, around lines 30-40, depending on your release. This has methods to GetMobileNumber and stuff, but we want to inject our own data into the object, so we had to query it in user2, and add the new fields in the object.
var user = GlideUser.getUserByID(userSysIds[index]);
var user2 = new GlideRecord('sys_user');
user2.get(userSysIds[index]);
var pager = user2.u_pager;
var pagerProv = pager.replace(/[\d.]/g, '') + user2.u_pager_provider;
if (!user || !user.getID())
continue;
var userProfileDetail = {
user: {
sys_id: userSysIds[index],
avatar: user.getAvatar() || "",
initials: user.getInitials() || "",
name: user.getFullName() || "",
title: user.getTitle() || "",
email: user.getEmail() || "",
pagerProvider: pagerProv || "",
pager: pager || "",
contact_number: user.getMobileNumber() || user.getBusinessNumber() || ""
}
};
userProfiles.push(userProfileDetail);
Great, with the new data in hand, now we need to go upstream to edit what calls this script include.
https://www.servicenow.com/community/developer-articles/how-to-edit-the-on-call-roster-and-escalation-details-modal/ta-p/2330069