Skip to main content

Run If or a regular conditional action


Outside of run ifs having 1 output path vs 2 when discussing a conditional action, what are the pros/cons of using either?

Is there a large enough performance difference between the two to warrant one over the other?

More specifically, even in a situation where you only need one path, does it really matter which action is used?

This is really a matter of personal preference rather than a performance question.  I would consider the maintainability aspect: if you come back to revisit a workflow years later, which approach would help you quickly understand the original intent best?


Hi @JiwanFilembar



 



Why to use a conditional branch when you only need to implement 1 action in a Yes OR a No condition.



 



The conditional branch is used for when you need to implement 2 different actions based on a Yes AND a No condition : if yes then do something Else (if No then) do something else. As supposed they have to happen in the same time but differently.



 



The impact that should be considered are not only from the workflow running engine (execution) but also from the designer (design).



 



What do you think about the following C# implementation as an example ?



 



































Bad





Good





if (something) {



  doSomething ();



} else {



}





if (something) {



  doSomething ();



}





Conditional branch Action ?





 





Run If Action ? 



 



 





 



Doing the Bad way brings complexity.



 



Performance impact is probably not significantly visible or null. It all depends on how those actions are implemented : which coding language is used behind and how it's implemented ? Is Nintex or the compiler of the coding language interpret empty condition blocks in language machine adding more pointer in the stack for nothing ? All solutions and/or languages has its own best practices.



 



Consider also that the Run if and Condition branch actions impact differently the load and the view of your workflow in the designer and starting to add 10 or more of conditional branch actions instead of Run If action have a higher impact.  



 



Another example :



































Good





Bad





if (something) {



  doSomething();



}



else {



  doSomethingElse();



}





if (something) {



  doSomething();



}



if not (something) {



  doSomethingElse();



}





1 Conditional branch Action





2 Run If actions





 



Doing the Bad way bring complexity and is definitely less performant as the condition will be verified 2 times.   Again, it all depends on how the no-code action is interpreted in code. Remember when you're using no-code solutions you don't know how it’s coded. I wish I could have a look on the code and do reflection of it to be more precise.



 



With that being said I don't think the performance impact is a big deal here for both workflow engine and designer. It mainly add complexity from the designer.



 



But don’t ignore those little things that can when done in a million times become big. Also consider someone will retake it after you. 



 



My2Cents,



Cecilia ^^


hi @JiwanFilembar 



 



So, Run If or a regular conditional action?



 



@DavidL2 is right as this is about personal preference or organization preference. I like that @cecilia-penha has done a deep dive into the matter (Interesting read!).



 



Condition Evaluation



Both the Run If and Condition Branch will evaluate all the conditions as a Boolean outcome - True or False.



The Conditions to evaluate against are pretty comprehensive. Evaluate a Valueworkflow variables, List Lookup and Workflow Context.



Truly advance scenarios can be realized using the combination of multiple conditions - And or Or.



 



Using Run If



My preference for using Run If is when the condition to assess is a simple and straight forward evaluation. If Status is Equal to "Approve". For more experienced developers, conditions can be up to a max of 2-3 conditions.





I would also update the action Label to help improve code readability.



 



Using Conditional Branch



I tend to use Conditional Branch when I am assessing complex logic even though there is only 1 outcome to process. I define complex logic as 3-5 or more conditions to evaluate. 



The complex logic should always evaluate to a True (a 'Yes' outcome) which is what we planned for.



The complex logic may evaluate as False (a 'No' outcome) simple because an approval manager has left the company (and his email or system ID has been disabled or removed) or an admin changes a system settings. 



This is certainly something not planned for ... however it may occur, and when it does, it will certainly impact the workflow. 





In theory, this evaluation to False (a 'No' outcome) should not occur at all. However in the event that it does, this is where the the Defensive Coding portion will help to pinpoint the fault.



 



Summary



In my humble opinion, What really matters in deciding the usage of Run If or a regular conditional action for a single outcome comes to down



1. Readability



2. Personal Preference



3. Organization Preference



 



My preference is to use Run If when there is a simple evaluation.



and to use Conditional Branch when there is a complex evaluation.



 



Nuff said



 


Awesome @Garrett

Reply