Flow designer

William08
Tera Contributor

 Hi all,

 

For a RITM Mutiple Sc task is create now how to set the ritm state to closed incomplete if any of the Sc task state is closed incomplete similarly for closed skipped.

 

Thanks,

 

@Sonam Tiwari could you please help on this

3 ACCEPTED SOLUTIONS

Sonam Tiwari
Tera Guru

Hi @William08 ,

 

To you main flow you, you can add a subflow in the below manner and pass it the ritm record.

SonamTiwari_0-1690875499927.png
The subflow looks something like this

SonamTiwari_1-1690875557578.pngSonamTiwari_2-1690875577248.png


Initializing a flow var in second step so that futher in for each step we can track all the states of child tasks from which we then need to check if any one is closed complete or incomplete or skipped.

SonamTiwari_3-1690875646041.png



SonamTiwari_4-1690875658055.png

 

SonamTiwari_5-1690875669531.png

and so on.

SonamTiwari_6-1690875683707.png

I had to use bit of script because couldn't track all the child states at once to check one of them is in a specific state like (complete, incomplete or skipped).

Not always a good idea to do too much scripting in flows if not required. 

This is working fine for me. Please test once. 

Also as @sleepycrown  said, we have alternative ways to do it and BR is one of them as well. Like you can attach this subflow to any other flow with similar requirement, same way you can make use of BRs to have a common solution.

 

Thanks

View solution in original post

OlaN
Giga Sage
Giga Sage

Hi,

I would recommend setting the state in the Flow/Workflow based on the outcome of the SCTASK.

I believe it is considered bad practice to create custom business rules on the sc_req_item table, because there is so many other things going on in these tables concerning stages and states.
I've spent some time looking for a reference for this, but cannot find it at the moment (believe it was on the Docs).

View solution in original post

If you can provide reference that indicates it’s not a good practice to have BR on sc_req_item, I would appreciate it as I cannot find it either. I’ve never seen it mentioned nor from ServiceNow. There are plenty of baseline rules on many tables in the platform; with good run conditions and a concise script, there should be no issues. Empirically, I’ve not noticed any of my BRs on sc_req_item causing any performance impact and never shows up in long running jobs/processes. It’s also never showed up in my instance health reports from ServiceNow. 


I mean, this is what business rules are for…

 

 

A business rule is a server-side script that runs when a record is displayed, inserted, updated, or deleted, or when a table is queried.

Use business rules to accomplish tasks like automatically changing values in form fields when certain conditions are met, or to create events for email notifications and script actions.”
 

View solution in original post

8 REPLIES 8

sleepycrown
Giga Guru

Hi there,

 

There are many ways to accomplish this. I recently created a solution for my organization based on the same problem statement. I ended up creating a before business rule that runs on sc_req_item that evaluates it's child sc_tasks for their state, setting the RITM state based on that, and doing the same from the RITM to the sc_request. For example, if all child sc_task records are Closed Incomplete, the RITM becomes Closed Incomplete, and if all RITMs are Closed Incomplete, the sc_request also becomes Closed Incomplete.

 

There is a baseline business rule called task closer that is responsible for setting a default state upon completion; however, this doesn't allow you to dynamically set the state based on the state(s) of the related child records. I left this in place and execute my business rule at a higher order (so after task closer). 

Hi @sleepycrown Thanks a lot

Sonam Tiwari
Tera Guru

Hi @William08 ,

 

To you main flow you, you can add a subflow in the below manner and pass it the ritm record.

SonamTiwari_0-1690875499927.png
The subflow looks something like this

SonamTiwari_1-1690875557578.pngSonamTiwari_2-1690875577248.png


Initializing a flow var in second step so that futher in for each step we can track all the states of child tasks from which we then need to check if any one is closed complete or incomplete or skipped.

SonamTiwari_3-1690875646041.png



SonamTiwari_4-1690875658055.png

 

SonamTiwari_5-1690875669531.png

and so on.

SonamTiwari_6-1690875683707.png

I had to use bit of script because couldn't track all the child states at once to check one of them is in a specific state like (complete, incomplete or skipped).

Not always a good idea to do too much scripting in flows if not required. 

This is working fine for me. Please test once. 

Also as @sleepycrown  said, we have alternative ways to do it and BR is one of them as well. Like you can attach this subflow to any other flow with similar requirement, same way you can make use of BRs to have a common solution.

 

Thanks

Community Alums
Not applicable

this subflow is giving internal server error while i try to test it