My Approvals widget doesn't work

Stergios Stergi
Mega Guru

Hello,

I have an issue regarding the My Approvals Widget on the index page of the ServiceNOW Portal.

If a user has the Itil role and the business_stakeholder role, then the widget is stuck on Loading Approvals... state.

If I remove the Itil role from the user then the widget works fine.

 

Can someone help me with this?

Thank you in advance!

 

Server Script

 

g_approval_form_request = true;
 
//we get only a max number of elements to avoid to have a big list of it
var maxNumberOfItemsInTheList = parseInt(options.max_number_of_elements_shown_on_the_list);
//set 10 if maxnumber is undefined, empty or negative value
maxNumberOfItemsInTheList = maxNumberOfItemsInTheList>0 ? maxNumberOfItemsInTheList : 10; 
var initRow = 0;
var lastRow = maxNumberOfItemsInTheList;
var currentPage = 0; //0 is the first page
if (input) {
// update pagination
currentPage = input.pagination.currentPage;
initRow = (currentPage * maxNumberOfItemsInTheList);
lastRow = initRow + maxNumberOfItemsInTheList;
 
if (input.op == 'approved' || input.op == 'rejected') {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
var isMine = gs.hasRole("approval_admin") || (gs.hasRole("approver_user") && isApprovalMine(app));
if (isMine) {
// 25.01.2022 MD update comments
if (input.comments && app.state == 'requested'){
        app.comments = input.comments; // Update comments if applicable
      }
app.state = input.op;
app.update();
if (currentPage > 0 && !input.pagination.hasNext && input.approvals.length == 1) {
currentPage--;
initRow = (currentPage * maxNumberOfItemsInTheList);
lastRow = initRow + maxNumberOfItemsInTheList;
}
}
}
}
}
 
data.ViewApprovalPageMsg = gs.getMessage("View approval page");
data.esignature = {
username:  gs.getUserName(),
userSysId: gs.getUserID(),
e_sig_required: GlidePluginManager.isRegistered('com.glide.e_signature_approvals')
};
 
var esigRequiredMap = {};
if (data.esignature.e_sig_required) {
var esigRegistryGR = new GlideRecord("e_signature_registry");
esigRegistryGR.addQuery("enabled", "true");
esigRegistryGR.query();
while(esigRegistryGR.next()) {
esigRequiredMap[esigRegistryGR.getValue("table_name")] = true;
}
}
 
var gr = new GlideRecord('sysapproval_approver');
gr.chooseWindow(initRow, lastRow);
var qc1 = gr.addQuery("state", "requested");
//if (input)
//  qc1.addOrCondition("sys_id", "IN", input.ids);
data.myApprovals = getMyApprovals();
gr.addQuery("approver", data.myApprovals);
gr.orderBy("sys_created_on");
gr.query();
var rowCount = gr.getRowCount();
var approvals = [];
var ids = [];
var source_tables = [];
 
while (gr.next()) {
  var task = getRecordBeingApproved(gr);
if (!task.isValidRecord())
continue;
 
  ids.push(gr.getUniqueValue());
  var t = {};
  t.number = task.getDisplayValue();
  t.short_description = task.short_description.toString();
  if (gr.getValue("approver") != gs.getUserID())
  t.approver = gr.approver.getDisplayValue();
  if (task.isValidField("opened_by") && !task.opened_by.nil())
  t.opened_by = task.opened_by.getDisplayValue();
 
  // requestor >> opener
  if (task.isValidField("requested_by") && !task.requested_by.nil())
  t.opened_by = task.requested_by.getDisplayValue();
 
  t.start_date = task.start_date.getDisplayValue();
  t.end_date = task.end_date.getDisplayValue();
  t.quantity = task.quantity.getDisplayValue();
  t.table = task.getLabel();
  if (task.getValue("price") > 0)
  t.price = task.getDisplayValue("price");

 

1 ACCEPTED SOLUTION

Stergios Stergi
Mega Guru

Hello, I have found the culprit. There was a BR that limited the access on RITMS and INC based on assignment group.
I tweaked to not run for users that were Approvers and Fulfillers -problem solved!

View solution in original post

3 REPLIES 3

Stergios Stergi
Mega Guru

Hello, I have found the culprit. There was a BR that limited the access on RITMS and INC based on assignment group.
I tweaked to not run for users that were Approvers and Fulfillers -problem solved!

Hi @Stergios Stergi ,

 

Can you please tell whether that BR is OOB , IF is which is that, even I am facing that issue.

 

Thanks 

Hi @Neelavathi M ,

 

No it is not OOB. It's a custom BR.