The CreatorCon Call for Content is officially open! Get started here.

Run a flow - Reject all RITM approvals greater than 45 days old

GP001
Tera Contributor

Run a flow - Reject all RITM approvals greater than 45 days old

1. Set approval status to Rejected
2. Set RITM state to Closed Incomplete
3. Run the flow on every Tuesday 7 AM CST.
4. Rejection Comment:
"This request was cancelled as the approver did not approve in the last 45 days."

Could anyone please suggest on it. Thank you!

1 ACCEPTED SOLUTION

@GP001 

After approval is rejected, your catalog workflow/flow should automatically cancel the RITM approval fields. Is it not happening? then it's advisable to check catalog workflows.

OR you can add another "update record" action in the new flow to update RITM record state.

SwapnaAbburi_0-1703876692209.png

 

View solution in original post

6 REPLIES 6

Tushar
Kilo Sage
Kilo Sage

Hi @GP001 

 

Create a new flow and add schedule trigger onto the canvas with below configuration -

  • Run on: Recurring
  • Frequency: Weekly
  • Day of week: Tuesday
  • Time of day: 7:00 AM CST

Add a below scheduled script action -

 

 

var 45DaysAgo = new GlideDateTime().addDays(-45);

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('approval', 'LIKE', 'RITM%');
gr.addQuery('sysapproval', 'LIKE', 'Pending');
gr.addQuery('sys_updated_on', '<=', 45DaysAgo);

gr.query();

while (gr.next()) {
  var ritm = new GlideRecord('sc_req_item');
  ritm.get(gr.sysapproval.getRecord());

  ritm.approval = 'Rejected';
  ritm.state = 'Closed Incomplete';
  ritm.work_notes = 'This request was cancelled as the approver did not approve in the last 45 days.';
  ritm.update();
}

 

 

Thanks,

Tushar

GP001
Tera Contributor

Hi Tushar,

I appreciated your update. But i need a flow designer on the above requirement instead of script.

 

Swapna Abburi
Mega Sage
Mega Sage

@GP001 

1. Create a new Flow with below trigger

SwapnaAbburi_0-1703871242123.png

 

2. Add an action "Lookup Records" with condition as in below Screenshot

SwapnaAbburi_1-1703871316614.png

 

3. Use Flow logic "For each"

SwapnaAbburi_2-1703871389745.png

 

4. For each item returned from above logic, you can add action "Update Record" to reject the approval

SwapnaAbburi_3-1703871452173.png

 

Hi Swapna,

Thanks a lot for your reply. Upto above is fine, but i need to update the associated RITM state is Closed incomplete and status is Rejected. Could you please update here. Thank you so much!