- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2023 06:28 PM
Hi All,
I am creating a flow designer, and I want to set the ask for approval cancelled if the record is updated .
How can I set the flow Designer.
Thank you very much.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2023 08:03 PM
Hey @Chang Shuang :
May I know why you want to cancel the approval after an update over the record, and what on what update do you want to perform this action like a state change of the parent record?
Mark this as Helpful / Accept the Solution if this clears your issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2023 08:03 PM
Hey @Chang Shuang :
May I know why you want to cancel the approval after an update over the record, and what on what update do you want to perform this action like a state change of the parent record?
Mark this as Helpful / Accept the Solution if this clears your issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2023 09:47 PM
HI Goutham,
I want to cancel the approval request, after update one of fields of the table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2023 10:17 PM
I would suggest writing a Business rule on the table where you going to update the record
Set the BR condition on the <field> changes as the trigger
Set it to After update
Set Advanced to <True>
use the below script to close the approval record
var grApprovalRecord = new GlideRecord("sysapproval_approver");
grApprovalRecord.addQuery("document_id", <your record>.sys_id);
grApprovalRecord.query();
while (grApprovalRecord.next()) {
if (grApprovalRecord.state == "requested") {
new Workflow().cancel(grApprovalRecord); // Cancel approval workflow
grApprovalRecord.setWorkflow(false); // Prevents sending of emails
grApprovalRecord.state = "not_required";
grApprovalRecord.update();
}
}
// Group approval canceller
// Locate every Group approval and set to - No Longer Required
var grGroupApprovalRecord = new GlideRecord("sysapproval_group");
grGroupApprovalRecord.addQuery("parent", <your record>.sys_id);
grGroupApprovalRecord.query();
while (grGroupApprovalRecord.next()) {
if (grGroupApprovalRecord.approval == "requested") {
new Workflow().cancel(grGroupApprovalRecord); // Cancel group approval workflow
grGroupApprovalRecord.setWorkflow(false); // Prevents sending of emails
grGroupApprovalRecord.approval = "not_required";
grGroupApprovalRecord.update();
}
}
Mark this as Helpful / Accept the Solution if this clears your issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2023 06:27 AM
hi Goutham,
Thanks for your repay.
I add this gs.info code before the code you shared with me.
I found that it will give several log messages at the same time when I update the record.