Autoclose RITM after 3 days

dev_K
Tera Contributor

Hi All,

 

 

I have a catalog item which creates a task. Once the task is closed the RITM is assigned to the requestor for him to close it. I want however to close it if user does not do it himself after 3 days. 

 

How to approach it?

 

 

thanks!

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hello,

 

Considering its a custom requirement. You can achieve this via "Schedule Job" or "Flow Designer":-->

 

Example Script :-

 

using schedule Job :-

var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('state', 'Closure'); // Assuming "Closure" is the state where it's waiting for the requestor to close it
ritmGr.addQuery('sys_updated_on', '<=', gs.daysAgo(3));
ritmGr.query();

while (ritmGr.next()) {
ritmGr.state = 'Closed';
ritmGr.work_notes = "RITM automatically closed after 3 days of no action from the requestor.";
ritmGr.update();
}

using Flow :-

  • Create a Flow:

    • Navigate to Flow Designer and create a new flow.
    • Set the trigger to When Task is Closed.
  • Wait Condition:

    • Add a Wait for Condition action that waits for 3 days.
    • Use the "Wait for" action and set it to wait for 72 hours (3 days).
  • Check RITM Status:

    • Add a Condition after the wait to check if the RITM's state is still in a state indicating it's awaiting user closure (e.g., "Pending Closure").
  • Close the RITM:

    • If the RITM is still not closed, add an Update Record action to change the state of the RITM to "Closed" or any other appropriate state.

 

 

View solution in original post

6 REPLIES 6

Ravi Gaurav
Giga Sage

Hello,

 

Considering its a custom requirement. You can achieve this via "Schedule Job" or "Flow Designer":-->

 

Example Script :-

 

using schedule Job :-

var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('state', 'Closure'); // Assuming "Closure" is the state where it's waiting for the requestor to close it
ritmGr.addQuery('sys_updated_on', '<=', gs.daysAgo(3));
ritmGr.query();

while (ritmGr.next()) {
ritmGr.state = 'Closed';
ritmGr.work_notes = "RITM automatically closed after 3 days of no action from the requestor.";
ritmGr.update();
}

using Flow :-

  • Create a Flow:

    • Navigate to Flow Designer and create a new flow.
    • Set the trigger to When Task is Closed.
  • Wait Condition:

    • Add a Wait for Condition action that waits for 3 days.
    • Use the "Wait for" action and set it to wait for 72 hours (3 days).
  • Check RITM Status:

    • Add a Condition after the wait to check if the RITM's state is still in a state indicating it's awaiting user closure (e.g., "Pending Closure").
  • Close the RITM:

    • If the RITM is still not closed, add an Update Record action to change the state of the RITM to "Closed" or any other appropriate state.

 

 

Hi!

 

I opted for the flow solution.

 

It seems to work but only when I perform test in a flow, when I dont the RITM is not updated. Why this happens?

 

 

Here is the flow:

 

Applies only to specific catalog items, when the status changes to work in progress:

dev_K_0-1724409059847.png

 

For testing I set 5 sec:

dev_K_1-1724409119028.png

 

 

then after 5 sec it will check if the status is still closed complete and if true, it will change it to closed complete:

 

dev_K_2-1724409182287.png

 

dev_K_3-1724409202806.png

 

 

 

 

Testing a sc_task record:

 

dev_K_4-1724409241866.png

 

then the record is updated correctly:

 

dev_K_5-1724409323034.png

 

but when I dont do those test for the sc_task record the RITM status does not change... why?