Complex Flow with flow variables in flow designer

Community Alums
Not applicable

Greetings everyone

 

Iam tasked with designing workflows for intricate business processes and using flow designer to develop the flows. As part of this task, I encounter numerous conditional loops where various values are updated, and in certain scenarios, the flow terminates. I have contemplated two approaches to tackle this:

  1. Creating flow variables and assigning them values within each loop. The subsequent actions can then be determined based on these flow variables. This method ensures that there is only one update action at the end of the flow, which I believe would be easier to monitor and manage.

  2. Incorporating the update action within each loop. While this approach may result in multiple instances of the update action being called, it might simplify the development process.

can you help me with the best practice on this ? what is the best approach ?

 

Thank you.

4 REPLIES 4

Riya Verma
Kilo Sage
Kilo Sage

Hi @Community Alums ,

 

Hope you are doing great.

 

The recommended approach would be to create flow variables and assign them values within each loop. This method ensures that there is only one update action at the end of the flow, making it easier to monitor and manage. By using flow variables, you can store and update values as needed throughout the loop iterations, and then make decisions based on these variables to determine the appropriate actions.

 

Reference script to embed the logic :

 

var flowVariable1;
var flowVariable2;

for (var i = 0; i < loopIterations; i++) {
  // Perform operations within the loop

  if (condition1) {
    flowVariable1 = value1;
  } else {
    flowVariable1 = value2;
  }

  if (condition2) {
    flowVariable2 = value3;
  } else {
    flowVariable2 = value4;
  }
}

// Perform the update action based on the flow variables
if (flowVariable1 === value1 && flowVariable2 === value3) {
  // Perform update action 1
} else if (flowVariable1 === value2 && flowVariable2 === value4) {
  // Perform update action 2
} else {
  // Handle other scenarios or perform default action
}

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Community Alums
Not applicable

@Riya Verma  - The question is on the flow designer and not on the script.Any idea?

MateoBilandzija
Tera Expert

Hi can you show some Errors/Logs or Pictures where we can help you then out ?

 

Rishabh10
Tera Contributor

Without more details on the context where you are implementing this, I would recommend going with approach 1 unless you need the update to drive other logic. 

Minimize the number of updates on the actual record as it would slow down the instances and will cause a headache as more records get processed simultaneously