SCTASK auto closer logic in flow designer

Barathk
Tera Contributor

Hi All,
As per my requirement i have created 3 SCTASK and in else condition I am creating 2 SCTASK , for this both condition I apply the auto SCTASK closer logic .
once the SCTASK created based on created date the all sctask should be auto close in 7 days form creation.

here I am attaching the flow snap for reference , can any one help for the close logic.

Thanks,

Barath

4 REPLIES 4

dhanrajb
Tera Guru

Hi @Barathk ,

 

You can create a scheduled job to close the SCTASKs after 7 days. Write some code like below in your scheduled job and define the frequency of your scheduled job. For example, trigger the scheduled job for each 1 hour.

 

var scTask = new GlideRecord('sc_task');
scTask.addEncodedQuery('sys_created_onRELATIVELT@dayofweek@ago@7');
scTask.query();
while(scTask.next()){
    scTask.state = '3';
    scTask.update();
}

 

Here the value of state mentioned is Out of the box value. Please confirm with your state value too and give the value accordingly.

 

Regards,

Dhanraj.

Arpan Baishya
Kilo Sage

Hi @Barathk,

 

I came up with a sample flow that you can refer to.

ArpanBaishya_0-1717166185635.png


You can set the trigger according to your need.


ArpanBaishya_1-1717166251187.png


Let me know if this helped you.

 

 

Hi @Arpan Baishya 
I have added in flow and I have given the closer time 2mints for testing.
its not working, can you please suggest.

Barathk_1-1717416988215.png

 

Hi @Barathk,

 

What trigger are you using at the start of the flow? Also, based on the trigger, check out the list of flow executions to understand whether the flow ran for any test records that you may have created.