Service Portal - My Pending Approvals Scripted list help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 04:13 AM - edited 08-28-2024 07:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 04:51 AM
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
No AI was used in the writing of this post. Pure #GlideFather only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 04:23 AM
Thanks the HREF is correct - It doesn't display the list on the top menu what the approvals are like the My Open Items.