Skip to content

Commit 1275adb

Browse files
authored
ServiceNow Catalog Request Approval Chain Preview (#2620)
* Create Readme.md * Create script include.js * Create client script.js
1 parent 3acdabb commit 1275adb

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This project adds a dynamic preview feature to Service Catalog items, allowing users to see the full approval chain before submitting a request. It improves transparency, reduces confusion, and helps users understand who will be involved in the approval process based on their selections.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function onLoad() {
2+
var ga = new GlideAjax('ApprovalChainHelper');
3+
ga.addParam('sysparm_name', 'getApprovers');
4+
ga.addParam('sysparm_item_id', g_form.getUniqueValue());
5+
ga.getXMLAnswer(function(response) {
6+
var approvers = JSON.parse(response);
7+
var message = 'This request will be approved by: ' + approvers.join(', ');
8+
g_form.showFieldMsg('requested_for', message, 'info');
9+
});
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var ApprovalChainHelper = Class.create();
2+
ApprovalChainHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
getApprovers: function() {
4+
var itemId = this.getParameter('sysparm_item_id');
5+
var userId = gs.getUserID();
6+
7+
var approvers = [];
8+
9+
// Example logic: fetch approval rules based on item and user
10+
var ruleGR = new GlideRecord('sysapproval_approver');
11+
ruleGR.addQuery('document_id', 80f8920bc3e4b2105219daec050131e3);
12+
ruleGR.query();
13+
14+
while (ruleGR.next()) {
15+
approvers.push(ruleGR.approver.name.toString());
16+
}
17+
18+
return JSON.stringify(approvers);
19+
}
20+
});

0 commit comments

Comments
 (0)