Service Portal - My approval list does not show delegate user's approval list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2017 11:37 PM
Hi,
We are using Istanbul version. In Service Portal page, "My approval" list does not show the delegate user's approval list.
However, these are getting displayed in "Self service -> Approvals assigned to me".
Could you please let me know how to show these in "Service Portal" page?
thanks
guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2017 11:46 PM
Hi Guru
The displaying of delegates in the native ui is being handle through a business rule called getMyApprovals. There is a function with similar name, i believe you may use this and add to Server script of your approval widget. Just modify the code a bit to push to your data array rather than doing a return value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 11:31 AM
Below is the server side code for a "My Delegated Approvals" widget.
I cloned the existing Approvals widget and then modified the service side code based on Regina's advice.
This widget will display all approvals delegated to the current user (with the exception of their actual real approvals that are not delegated)
---------------------------------------------------------------------------
if (input && input.op) {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
}
data.ViewApprovalPageMsg = gs.getMessage("View approval page");
var approvals = [];
var ids = [];
var user_name = gs.getUserID();
var array_of_ids = new Array();
var i = 0;
array_of_ids[i++] = new String(user_name);
//query to find where the current user is listed as a delegate
var g = new GlideRecord("sys_user_delegate");
g.addQuery("delegate", user_name);
g.addQuery("approvals", "true");
g.addQuery("starts", "<=", gs.daysAgo(0));
g.addQuery("ends", ">=", gs.daysAgo(0));
g.query();
while( g.next()) //loop thru the returned results and populate the array
array_of_ids[i++] = new String(g.user);
for (i=0; i< array_of_ids.length; i++) //step thru the array populated above to display the delegated approvals
{
if (array_of_ids[i] != user_name) //do not show approvals which are not delegated
{
var gr = new GlideRecord('sysapproval_approver');
gr.setLimit(50);
var qc1 = gr.addQuery("state", "requested");
if (input)
qc1.addOrCondition("sys_id", "IN", input.ids);
gr.addQuery("approver", array_of_ids[i]);
gr.orderBy("sys_created_on");
gr.query();
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 (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.toString();
t.end_date = task.end_date.toString();
t.table = task.getLabel();
if (task.getValue("price") > 0)
t.price = task.getDisplayValue("price");
if (task.getValue("recurring_price") > 0)
t.recurring_price = task.getDisplayValue("recurring_price");
t.recurring_frequency = task.getDisplayValue("recurring_frequency");
var items = [];
var idx = 0;
var itemsGR = new GlideRecord("sc_req_item");
itemsGR.addQuery("request", task.sys_id);
itemsGR.query();
if (itemsGR.getRowCount() > 1)
t.short_description = itemsGR.getRowCount() + " requested items";
while (itemsGR.next())
{
var item = {};
item.short_description = itemsGR.short_description.toString();
if (itemsGR.getValue("price") > 0)
item.price = itemsGR.getDisplayValue("price");
if (itemsGR.getValue("recurring_price") > 0)
{
item.recurring_price = itemsGR.getDisplayValue("recurring_price");
item.recurring_frequency = itemsGR.getDisplayValue("recurring_frequency");
}
if (itemsGR.getRowCount() == 1)
{
item.variables = $sp.getRecordVariablesArray(itemsGR);
t.short_description = itemsGR.short_description.toString();
}
items[idx] = item;
idx++;
} //end while (itemsGR.next())
var j = {};
j.sys_id = gr.getUniqueValue();
j.table = gr.getRecordClassName();
j.task = t;
if (task)
j.variables = $sp.getRecordVariablesArray(task);
j.items = items;
j.state = gr.getValue("state");
j.stateLabel = gr.state.getDisplayValue();
approvals.push(j);
}
} //end check to not show approvals which are not delegated (ie current user id)
data.ids = ids;
data.approvals = approvals;
}
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 02:09 PM
i am restricting One catalog item("Active Checking Box") of approval records to Delegates Users by Using Read ACL's it is Working fine in ITIL side .
but coming to Portal the that specific item of approvals records are still showing in Delegate portal view, So how to exclude those records...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 02:08 PM
i am restricting One catalog item("Active Checking Box") of approval records to Delegates Users by Using Read ACL's it is Working fine in ITIL side .
but coming to Portal the that specific item of approvals records are still showing in Delegate portal view, So how to exclude those records...