
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-23-2020 10:50 AM
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.
2) Edit Scripted Rest Resource: escalations (within API OnCallRotation)
(note, this will likely result in a skip at your next upgrade, but that's probably unavoidable and a side cost of this solution)
escalations
Edit line 14 to point to the new SI.
var escalationPathUtil = new OCEscalationPathUtilSTU();
3) Edit the UI Macro that makes up the right side of the modal window.
Update UI Macro: oc_audience_avatars
Add another LI element to add another row in the modal. In our case we copied the phone stanza, and put pager right after it (and before the email LI).
<li class="icon icon-application-generic defaultCursor">
<span class="sr-only">${gs.getMessage('Pager ')}</span>
<span class="avatar-info-item oc-truncate" uib-tooltip="{{audienceDetail.user.pager || form.notAvailable}}" tooltip-class="oc-truncate-tooltip" tooltip-placement="bottom" tooltip-enable="false">
<a ng-if="audienceDetail.user.pager" aria-label="{{form.pagerLabel}} {{audienceDetail.user.pager}}" href="mailto:{{audienceDetail.user.pagerProvider}}">{{audienceDetail.user.pager}}</a>
<span ng-if="!audienceDetail.user.pager" aria-label="{{form.contactNumberLabel}} {{form.notAvailable}}">{{form.notAvailable}}</span>
</span>
</li>
4) (Optional) - Create message/label elements referenced in the macro
Update UI Page: $on_call_who_and_escalation
In the template section for the above macro, add messages for the new Pager fields.
Find $scope.form around line 764, and add after it one new line for the label for Pager:
$scope.form.pagerLabel = i18n.getMessage("Pager");
And it's just that easy! 😛
- 1,261 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for this article. I didn't have to add a new field but just update the title field and didn't know where this was being done.
One thing to note though is that you don't have to modify the OOB OCEscalationPathUtilSNC script include. You can override (or add) methods in OCEscalationPathUtilSNC in the OCEscalationPathUtil script include, which is editable. This should eliminate step #2