- 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
06-22-2023 01:27 AM
@babbi @thaduri sai Could you please mark my answer as correct if it managed to address your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 01:35 AM
Script is working fine but we need in UI action.
How can we change this script into UI action.
Can you please help me.
Thanks
Saikrishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 02:24 AM
Create a new UI Action on your table. Simply copy and paste the code shared earlier inside the script field of the UI Action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 02:29 AM
Thankyou so much @Sandeep Rajput ,
We have existing UI action button like (Reset to New) there we have implement this.
And how to add conditions like state changes from (assess or authorize) changes to (new).
Thanks,
Saikrishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 03:34 AM
@babbi You will not be able to apply changesFrom and changesTo in the condition field of UI Action. These methods work only in case of business rule as it has access to the current and previous object.
In UI Action, you only have current object, hence you can apply any state level check on (current.state=='new') etc.