UI actions not working in custom application scope

Tyler Johnson
Tera Expert
Currently the below code works perfectly if used in global scope. When trying to put it in a custom scope it no longer functions . it just redirects to the code and does not update form. The table trying to be updated with this code is dms_decision.




______ Working in Global application________

UI Action:

try{
new global.ApprovalUtil().requestApproval(current);
action.setRedirectURL(current);
}
catch (err) {
var errorMessage = "Error: I could not work";
}



Script Include:

var ApprovalUtil = Class.create();
ApprovalUtil.prototype = {
initialize: function() {
},

requestApproval: function(current){
var gdt = new GlideDateTime();
current.approval = 'requested';
current.u_requested_approval = gdt.getDisplayValue();
current.update();
},

approveApproval: function(current){

var gdt = new GlideDateTime();
current.u_approved_on = gdt.getDisplayValue();
current.approval = 'approved';
current.update();
},

type: 'ApprovalUtil'
};
 
 
When i change the Script include to a custom scope and UI action to a custom scope it no longer works
******BROKEN CODE*****
 
UI Action: (Application changed to Custom application over global)
try {
new x_g_tyl2_cust.approvalUtil().requestApproval(current);
action.setRedirectURL(current);

}
catch (err) {
var action ="Request Approval";
var errorMessage = "Error: We couldn't "+action+" because " + global.JSON.stringify(err);
gs.addErrorMessage(errorMessage);
gs.error(errorMessage);
}
 
Script Include: (Changed to Custom Application and accessible from All application scopes)
 
var approvalUtil = Class.create();
approvalUtil.prototype = {
initialize: function() {},

requestApproval: function(current) {
var gdt = new GlideDateTime();
current.approval = 'requested';
current.u_requested_approval = gdt.getDisplayValue();
current.update();
},

type: 'approvalUtil'
};
1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Check your script include "ApprovalUtil" if Accessible from is set as All application scopes

Best Regards
Aman Kumar

View solution in original post

3 REPLIES 3

Aman Kumar S
Kilo Patron

Check your script include "ApprovalUtil" if Accessible from is set as All application scopes

Best Regards
Aman Kumar

It is currently set to accessible from all application scopes with the issue persisting. 

Are you getting error with this?

What I have observed, getDisplayValue() exhibits issue in scoped app

Best Regards
Aman Kumar