Show state 'Waiting for Approval' and approver name for which It is pending in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 09:15 AM
hi
I already see that on RITM the state is visible as "Waiting for Approval"
but how do I add approvers for which it is pending ?
In which widget shall I do the modifications ?
Please help if anybody has implemented the same and has code template.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 11:29 AM
Hello,
you do not need to edit a widget for this, we solved it this way:
- Create a new field on the sc_req_item table to that will display the approver (we used a simple string field)
- Create a before business rule on the sysapproval_approver table. u_approver is the field we created ourselves, and we also have a condition set on the business rule:
(function executeRule(current, previous /*null when async*/) {
var qr = new GlideRecord('sc_req_item');
qr.get(current.document_id);
qr.u_approver = current.approver.name;
qr.update();
})(current, previous);
- Edit the Self Service view of the sc_req_item table to display your newly created field. This way it will show on the portal view of Requested Items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 12:06 PM
Thank you for your response.
Self service view has the approval field but it doesn't show up in the portal.
I wanted to understand if adding field in the view will work for portal?
Also in the second screenshot I am looking to add field "approval" in the "Your request has been submitted box" which will also have the "approver name" with whom it is pending in the same box.
Also in case of multiple approvers, will the above script work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 12:51 PM
Ah sorry, looks like our page is configured a bit differently. On our Requested Item page, we added the Form widget at the top of the page. This widget displays the fields of the Self Service view of the table.
If you do not want to add that widget to your page, and want to show your fields in the "Your request has been submitted" widget, you will have to change the server code of that widget. The code says by default
var fields = $sp.getFields(gr, 'number,state,priority,sys_created_on');
if (gr.getValue("sys_mod_count") > 0)
fields.push($sp.getField(gr, 'sys_updated_on'));
if (gr.getValue('price') > 0)
fields.push($sp.getField(gr, 'price'));
if (gr.getValue('recurring_price') > 0) {
var rp = $sp.getField(gr, 'recurring_price');
if (gr.isValidField("recurring_price"))
rp.display_value = rp.display_value + " " + gr.getDisplayValue("recurring_frequency");
fields.push(rp);
}
if (gr.isValidField("quantity"))
fields.push($sp.getField(gr, 'quantity'));
If you always want to show the approval field, you add the name of that field to the first line of this code. If you only want to add it when the state is requested, you will have to add a separate If-part to the code.
The code I provided will only show one approver in the field. If you have multiple approvers of an item you will have to edit the code a bit, but that depends on what exactly you want to show (just one long string of the different approvers, if multiple people need to approve, does the field need to update every time when one approver approves so he is removed from your field, ..)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2019 11:17 PM
I have brought the approval field.
Need help on bringing the approvers