Setting stage on Flow, Close Parent If Required BR not firing

Rich7
Tera Expert

In Flow Designer, I am setting Stages for the RITM based on if a RITM is rejected, complete or incomplete.  I would expect this to fire the "Close Parent if Required" Business Rule but it is not and need help to determine why.  My goal is to have the REQ state change to Closed Completed or Closed Incomplete once the RITMs are closed.

 

I would rather use the OOTB functionality and not have to use custom code.

 

Any help is greatly appreciated.

 

 

4 REPLIES 4

Community Alums
Not applicable

Hi @Rich7 I agree with your point to use OOTB functionality in this case "Close Parent if Required" Business Rule to update the RITM stages. Coming to why the BR is not getting triggered

1. Have you set the Flow stage value to - 'complete'? Its case sensitive here and instead of complete - if it is completed, then the BR wont trigger due to the condition

 

GaganKris_0-1736803926451.png

2. Are you updating the stage at the right stage? a screenshot flow causing the issue would be helpful

 

Please like/helpful if my response is in line with your expectation.

 

Regards,

Gagan k

 

Exactly this.

 

But I have a doubt...

 

I see in my personal instance (which is a clean instance) that the BR Close Parent if Required has a condition that looks for value 'complete'

DiogoSoares_0-1751296661974.png


However, that option doesn't exist

DiogoSoares_1-1751296805888.png

 

Am I the only one that have that inconsistency? Are the flow stages options seen in the flow designer the exactly same stages options seen in that dictionary entry stage of requested item table?

 

Thanks.

MackI
Kilo Sage

HI @Rich7 

 

I am using an IT Security Approval Busienss flow for this which is similar to you on my PDI

 

Solution: Flow Designer + Decision Table + Stage Configuration [ NO Code Solution]

Decision Table for REQ State Mapping:

Create a Decision Table (if you haven't already):Table: sc_req_item
Inputs: state (Choice list - representing the RITM state)
Outputs: request_state (Choice list - representing the desired REQ state)

Decisions:

| RITM State (state) | REQ State (request_state) | | :----------------- | :----------------------- | | 3 | 3 | | 4 | 4 | | 7 | 4 |
Note: The values 3, 4, and 7 typically correspond to "Closed Complete," "Closed Incomplete," and "Closed Skipped" respectively. Adjust if your instance uses different values.
 
Flow Designer: REQ Flow

Wait for All RITMs: In your main REQ flow, use a "Wait for" activity (e.g., "Wait for a specific duration of time," or, if you must ensure all are complete, a loop that rechecks the status of each RITM) to pause the flow until all related RITMs have reached a terminal state (Closed Complete, Closed Incomplete, or Closed Skipped). This is important because you only want to update the REQ state after all RITMs are finalized.

Get RITM States:Use a "Lookup Records" action to fetch all RITMs related to the current REQ.
Table: sc_req_item
Conditions: Request is current REQ (or however you link RITMs to the REQ)
Fields: Make sure you retrieve the state field.
Evaluate Decision Table:Use a "Decision" action (or a series of "If" actions depending on the complexity).
In the decision logic, loop through each retrieved RITM's state from the "Lookup Records" action. For simplicity you can assume if even one RITM is rejected, the REQ should be set to Closed-Incomplete
Use the state to evaluate the Decision Table you created in step 1 using a "Decision Table" action within your loop.Table: Select the decision table you created.
Inputs: Map the RITM's state to the state input of the Decision Table.
Execution: Set to "First matching decision" since you will want to prioritize Incomplete over Complete.
 
Here's how it addresses the firing of that business rule:

1. Explicitly Setting RITM State:

The solution emphasizes explicitly setting the RITM's state field to 3 (Closed Complete), 4 (Closed Incomplete), or 7 (Closed Skipped) within the RITM flow, particularly in the "IT Security Approval" section when an approval is rejected.

2. "Close Parent if Required" Business Rule Conditions:

The standard "Close Parent if Required" business rule is designed to run after an update on the sc_req_item table.
Its default condition is usually current.state.changes() && (current.state == 3 || current.state == 4 || current.state == 7).
How the Solution Triggers the Business Rule:

When the RITM flow updates the RITM record and sets its state to one of the closed states (3, 4, or 7), it satisfies the current.state.changes() and the state value condition of the business rule.
This update action triggers the "Close Parent if Required" business rule to execute.
 

3. Decision Table and Business Rule Script:

The solution incorporates a Decision Table to determine the appropriate REQ state based on the RITM states.
The modified script within the "Close Parent if Required" business rule then utilizes this Decision Table's output to set the REQ's state accordingly.
 
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer‌🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
MackI | ServiceNow Developer | 2 *Mainline Certification | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia

jMarshal
Mega Sage
Mega Sage

@Rich7 I'm experiencing this issue, also...and the resolution is a bit of a "doosey", as it kinda defeats the purpose for using Flow Designer IMO. @Community Alums is correct in identifying the source of the problem, the OOB BR condition is not being satisfied as you're likely not setting the stage "correctly".

You can see what I was doing in the screenshots below, which I assume is similar to what you are doing (which didn't/doesn't work)...and then see what I did to get it to work. I built this in a subflow which is called from the majority of my catalog item flows.

Essentially, you can't use the GUI to set the stage values in Flow Designer, you must "script it" to set that field (sc_req_item.stage) to the returned value of "complete", "closed_incomplete" or "closed_skipped" (exactly as that), to fix this.

...and I believe this issue goes well beyond my simple explanation and solution as well, to be honest.

While troubleshooting this, I removed the advanced condition from the OOB BR all together, setting it to trigger (on the "when to trigger" tab) as "active changes to false"...and yet it STILL did not work -- meaning, the function in the advanced script which fires (or doesn't fire) based on that OOB advanced condition (which I removed), has a built-in dependency on something that I wasn't able to ascertain from my investigation (couldn't find where to look at the script behind "SNC.RequestItem.closeParentRequest()")...and this maybe-kinda helps explain the reason why that advanced condition exists, perhaps(?)...but this is a bit of a "bad look" IMO. SN should probably fix this a lil bit better than expecting users to just troubleshoot this themselves and come up with this unintuitive "creative solution". 

Subflow to rollup RITM closure based on a specific SCTASK being closed (to determine "complete", "incomplete" or "skipped"):

jMarshal_0-1744047616950.png


This is what does NOT work:

jMarshal_2-1744047867406.png


This DOES work though:

jMarshal_1-1744047684333.png


...where the value behind the "Completed" oob option/choice that I'm using here is literally 'complete". 😑 😑 😑

This is what I did during my troubleshooting (below), which is why I'm confident this is ultimately something SN will have to fix or rely on this type of a "hackey fix" just so we can use "modern features" like Flow Designer?? C'moooon maaaaan.

jMarshal_4-1744048055702.png

jMarshal_3-1744048027907.png