Skip to content

Commit fca93f0

Browse files
Preview context record during approval (ServiceNowDevProgram#833)
1 parent 523c74c commit fca93f0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
While approving any request it was very hard until now to preview the record for which the approval was required. This UI action created on sysapproval_approver table will enable previewing the record before approval so that the approver can make an easy informed decision.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var TestScriptInclude = Class.create();
2+
TestScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
4+
getDocumentClass: function(){
5+
var sysId = this.getParameter("sysparm_sys_id");
6+
var gr = new GlideRecord("sysapproval_approver");
7+
if(gr.get(sysId)){
8+
return JSON.stringify({
9+
"table": gr.source_table.toString(),
10+
"document": gr.document_id.toString(),
11+
"title": gr.document_id.getDisplayValue()
12+
});
13+
}
14+
},
15+
16+
type: 'TestScriptInclude'
17+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
This script should be placed in the UI action on the table sysapproval_approver.
3+
This UI action should be marked as client callable script include.
4+
Use openContextRecord() function in the Onclick field.
5+
*/
6+
7+
function openContextRecord() {
8+
var rec = g_form.getDisplayValue("document_id");
9+
var gaSi = new GlideAjax("TestScriptInclude");
10+
gaSi.addParam("sysparm_name", "getDocumentClass");
11+
gaSi.addParam("sysparm_sys_id", g_form.getUniqueValue());
12+
gaSi.getXMLAnswer(function(response) {
13+
var answer = JSON.parse(response);
14+
var gp = new GlideModalForm(answer.title, answer.table, function(){});
15+
gp.addParm('sys_id', answer.document);
16+
gp.render();
17+
});
18+
}

0 commit comments

Comments
 (0)