Service Portal - My Pending Approvals Scripted list help

Wendy Peterson
Giga Guru

We have on our service portal "My open items" which shows a list of their open items for requests, incidents etc. They now want "My Pending Approvals" and have it show - Approving and Opened by and Created. I took the other script and updated it how i thought it would be but the list is blank. Any ideas? I have it going to the page it just doesn't show the approvals in the list at the top.

 

var max = 30;
var t = data;  // shortcut
t.items = [];

var u = gs.getUser().getID();

// Use record watchers to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'sysapproval_approver','filter':'state=requested^approver=' + u});

var st = new GlideRecord('sysapproval_approver');
if (st.isValid()) {
  st.addQuery('state', 'requested');
  st.addQuery('approver', u);
  st.orderByDesc('sys_updated_on');
  st.setLimit(max);
  st.query();
  
  while (st.next()) {
    if (!st.canRead()) continue;
    
    var a = {};
    a.state = st.getValue('state');
    a.approving = st.getValue('approving');
    a.opened_by = st.getDisplayValue('opened_by');
    a.created = st.getValue('sys_created_on');
    a.short_description = st.approving.nil() ? "(No description)" : st.approving;
    a.__table = st.getTableName();
    a.type = 'record';
    a.sortOrder = st.sys_updated_on.getGlideObject().getNumericValue();
    t.items.push(a);
  }
}

t.items.sort(function(a, b) {
  return b.sortOrder - a.sortOrder;
});
t.items = t.items.slice(0, max); // Only want first 30
t.count = t.items.length;

var link = {title: gs.getMessage('View my pending approvals'), type: 'link', href: '?id=approvals', items: []};
t.items.unshift(link); // Put 'View all requests' first

 

 

2 REPLIES 2

GlideFather
Tera Patron

Hi, I would focus on the part after "href:" in:

var link = {title: gs.getMessage('View my pending approvals'), type: 'link', href: '?id=approvals', items: []};

 ?id=approvals is indicating where the link will direct, if you want to change it, locate the desired page and try to change it here

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Thanks the HREF is correct - It doesn't display the list on the top menu what the approvals are like the My Open Items.