- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 08:13 AM
Hi Team,
We have a requirement in change request - In change request we have UI button (Reset to New).
In change we are added manuall approvals. Now the change is in Assess state waiting for approvals. Some of the groups are "Approved" and other groups are "Requested" state.
If change got (reset to new) state - The approved groups are still showing in groups approvals.
How can we acheive to cancel all approvals if change reset new through Ui action button.
Thanks,
Saikrishna
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 08:31 AM
@thaduri sai Create a business rule on Change Request table as follows.
Here is the BR script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var approvalRec = new GlideRecord('sysapproval_approver');
approvalRec.addQuery('document_id',current.sys_id);
approvalRec.query();
while(approvalRec.next()){
approvalRec.setValue('state','not_required');
approvalRec.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 02:36 AM
@babbi @thaduri sai Update the BR as follows.
function executeRule(current, previous /*null when async*/) {
// Add your code here
var approvalRec = new GlideRecord('sysapproval_approver');
approvalRec.addQuery('document_id',current.sys_id);
approvalRec.query();
while(approvalRec.next()){
approvalRec.setValue('state','not_required');
approvalRec.update();
}
var approvalGroupRec = new GlideRecord('sysapproval_group');
approvalGroupRec.addQuery('parent',current.sys_id);
approvalGroupRec.query();
while(approvalGroupRec.next()){
approvalGroupRec.setValue('approval','not_required');
approvalGroupRec.update();
}
})(current, previous);
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 01:40 PM
Hi @Sandeep Rajput, I have gone through your script. Its really helpful. I have a question, For my change, its updating from new to assess first, then manager approval is triggered and ones it is approved, then it will move to authorize state. Then a group approval will be triggered for CAB approval. Now if I use revert to new, i was able to move it to new state, but by using your code, I am seeing all the approvals are updating to "No longer required" including the approved ones. which is not correct. Cam you help me with this