- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 11:11 PM
How Can I Change Approval History on RITM to only Display Group Approval not User Approval details?
Hi Community colleagues, I would really appreciate your help with this, if it is even possible please.
On the RITM form, the 'Approval History' activities currently show a log of all the Users that have been sent an Approval Request, whom are part of the Approval Group and this is logged/displayed on the RITM Form view with lots of lines for every User Approval requested to approve the RITM.
However, if there are for example 10 Approval Group Users in that Group, there are 10 activities logged on the RITM form, which clogs up the RITM form view.
How can I customise so that only the Group Approval is referenced in the Approval History that is displayed on the RITM Form view, and when someone from that Approval Group approves the RITM, it only shows that line, not all the individual people whom were sent an approval request.
I don't want to show all the Approval History for every single approver user whom is part of an Approval Group.
I want to minimise the lines displayed on the RITM Form View for both the 'Approval History' and 'Activities' section, so that it is cleaner to view, also on the Service Portal View of the RITM status.
Is this at all possible and how would I configure this ?
Many thanks for any help/guidance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 12:46 AM
Hi @WazzaJC ,
To understand this better, would explain how this is controlled first of all OOTB.
1. This is a generic platform feature applicable for all other tables as well apart from Requested Item table using an OOTB business rule named "Approval Events (Task)". - https://instance.service-now.com/nav_to.do?uri=sys_script.do?sys_id=aea34678c61122710151b1b7fdf65762
2. Refer to code block line number from 68 to 80 where when ever there is an insert or update on sysapproval table and state of the record changes which it will when a new approval is inserted these lines of code will get triggered.
3. Within this code block, refer specific to line number 78 as mentioned below as well:
var approvalComment = getComment(isFD, getApproverUserName(current.approver), "requested to approve task");
4. getComment method is used to generate the lines which you see in Activity History for each approver which gets generated which is controlled in line number block from 42 to 48 as shown below:
function getComment(isFlowDesigner, username, comment) {
if (isFlowDesigner) {
var myComment = "{0} " + comment;
return gs.getMessage(myComment, username);
}
return username + " " + comment;
}
5. Now once these are generated final update is being made using line number from 166 to 170 as shown below:
if (typeof task.approval_history.setJournalEntry === 'function') {
task.approval_history.setJournalEntry(journal);
task.update();
return;
}
6. I would recommend not making this enhancement as these are core platform features and will add maintenance effort with future upgrade. However if you still want to proceed with this enhancement then follow the steps below:
7. Replace line number 79 with the new piece of code shared below:
updateTask(current, approvalComment);
with this below:
New Code:
if(current.source_table !='sc_req_item'){
updateTask(current, approvalComment);
}
8. Write a new After Insert BR on Group Approval Table which is "sysapproval_group" and use the script shared below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id',current.parent);
ritm.query();
if(ritm.next()){
ritm.approval_history = current.getDisplayValue('assignment_group') + ' requested to approve task';
ritm.update();
}
})(current, previous);
Result:
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 12:46 AM
Hi @WazzaJC ,
To understand this better, would explain how this is controlled first of all OOTB.
1. This is a generic platform feature applicable for all other tables as well apart from Requested Item table using an OOTB business rule named "Approval Events (Task)". - https://instance.service-now.com/nav_to.do?uri=sys_script.do?sys_id=aea34678c61122710151b1b7fdf65762
2. Refer to code block line number from 68 to 80 where when ever there is an insert or update on sysapproval table and state of the record changes which it will when a new approval is inserted these lines of code will get triggered.
3. Within this code block, refer specific to line number 78 as mentioned below as well:
var approvalComment = getComment(isFD, getApproverUserName(current.approver), "requested to approve task");
4. getComment method is used to generate the lines which you see in Activity History for each approver which gets generated which is controlled in line number block from 42 to 48 as shown below:
function getComment(isFlowDesigner, username, comment) {
if (isFlowDesigner) {
var myComment = "{0} " + comment;
return gs.getMessage(myComment, username);
}
return username + " " + comment;
}
5. Now once these are generated final update is being made using line number from 166 to 170 as shown below:
if (typeof task.approval_history.setJournalEntry === 'function') {
task.approval_history.setJournalEntry(journal);
task.update();
return;
}
6. I would recommend not making this enhancement as these are core platform features and will add maintenance effort with future upgrade. However if you still want to proceed with this enhancement then follow the steps below:
7. Replace line number 79 with the new piece of code shared below:
updateTask(current, approvalComment);
with this below:
New Code:
if(current.source_table !='sc_req_item'){
updateTask(current, approvalComment);
}
8. Write a new After Insert BR on Group Approval Table which is "sysapproval_group" and use the script shared below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id',current.parent);
ritm.query();
if(ritm.next()){
ritm.approval_history = current.getDisplayValue('assignment_group') + ' requested to approve task';
ritm.update();
}
})(current, previous);
Result:
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 06:19 AM
@shloke04 thank you very much for taking the time to provide me with this solution, I really do appreciate this, thanks very much ! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:47 AM
This can be done using an advanced Business Rule that prevents inserts into the Approval History journal field for that type of update. The BR should have an order higher than the order of the OOTB "Approval Events (Task)" BR from which this update originates.
if(current.approval_history.getJournalEntry(1).indexOf('requested to approve task') != -1) {
current.setAbortAction(true);
}