- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:50 AM
Currently, the only field on request items that shows approval information is stage and only tells you the status. I have an ask to show who the approver is on the list view.
I believe the only way to accomplish this is to copy the approver on the sys_approval table to the sc_req_item table. I created a field on the requested item field as Approval For(u_approval_for)
Business Rule condition. There are no actions, as i have used advanced
Code
(function executeRule(current, previous /*null when async*/) {
var requestitem = new GlideRecord('sc_req_item');
requestitem.get(current.document_id);
if(requestitem.isValidRecord()) {
sc_req_item.u_approval_for = current.approver + ',' + sc_req_item.u_approval_for;
requestitem.update();
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:50 PM
Harel, i fixed my problem
i switched my approval for field to be a reference field to the user table.
i modified the script to be
requestitem.u_approval_for = current.approver ;
and now the approval for field displays the approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 02:17 AM
and...?
I took your code and tried it in my instance and it worked - i could populate a field with the approver's sys_id.
What happened on your form?
btw, sc_req_item.u_approval_for; should also be requestitem.u_approval_for I think.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 09:12 AM
this is my current script: where should i make the change
(function executeRule(current, previous /*null when async*/) {
var requestitem = new GlideRecord('sc_req_item');
requestitem.get(current.document_id);
if(requestitem.isValidRecord()) {
requestitem.u_approval_for = current.approver + ',' + sc_req_item.u_approval_for; - i think you might want me to make the change here
requestitem.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 09:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 12:50 PM
Harel, i fixed my problem
i switched my approval for field to be a reference field to the user table.
i modified the script to be
requestitem.u_approval_for = current.approver ;
and now the approval for field displays the approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 11:58 AM
Yes, of-course. I did not realize that you were not using a reference field.
If you want to use a string field, use getDisplayValue().
harel