Conditional event doesn't trigger with complex expressions

I have a question about the conditional events. Does it validate only simple expressions like count > 5 or flag === true or it can validate a complex expression as well ? something like given below

${execution.getVariable("Flags").ABCCheckStart == true}

Because, I set the ABCCheckStart flag to true using below script :

var temp=JSON.parse(Flags);
temp.ABCCheckStart = true;

execution.setVariable("Flags", S(JSON.stringify(temp)));

and then I put below expression to validate the condition :

${execution.getVariable("Flags").ABCCheckStart == true}

But the conditional event doesn’t trigger. Am I missing something here ?

Thanks

Hello my dear! :smile:

try using the .prop() method to access your JSON property.

The .prop() method is used to access JSON properties when you are working with spinJSON, which in this case is the S() method you used.

So try doing it this way:

${execution.getVariable("Flags").prop("ABCCheckStart").value() == true}

Remember that, if your JSON has a property chained to another, you will have to go through all the properties until you reach the one you want to capture the value… let’s say that the ABCCheckStart property is inside property 3 that is chained to property 2 and 1, you would have to do it like this:

${execution.getVariable("Flags").prop("property1").prop("property2").prop("property3").prop("ABCCheckStart").value() == true}

Hope this helps
William Robert Alves

1 Like

Thanks @WilliamR.Alves for your detailed response. I will try your approach. I have one quick follow up question :

Can I use transient variables to trigger the conditional events ? Because I don’t want to save my variables used as flags in DB and contribute in increasing DB size.

:smile:

You can use setVariableLocal() and getVariableLocal() to create and fetch transient variables that will only be valid in the instance scope and will not be persisted in the database.

William Robert Alves

1 Like

Hi @WilliamR.Alves

I set the transient variable like this :

execution.setVariableLocal(“ABCCheckStart”, true);

And, I am validating it in the conditional event like below :

${execution.getVariableLocal(“ABCCheckStart”)}

When I trigger the instance, I get the following error

Am I missing something?

Thanks

Helly my friend!

I believe that for what you need, you can do it as follows below according to the prints.

I’m also leaving the BPMN file I made, so you can run it on your machine following the instructions I put highlighted in red.

If it does not serve your needs, please understand a little more about the context to be able to help you better.

**
mahaveer47-Process.bpmn (7.0 KB)
**

1 Like

@WilliamR.Alves Thanks for the response

I tried the BPMN provided by you but after running a instance, I see that it created a variable in ACT_RU_VARIABLE table so the local variable is getting saved in the DB which is not needed in my requirement.

Please let me know if I misunderstood the concept.

Thanks

@mahaveer47 hello :smiley:

The ACT_RU_VARIABLE table saves the variables temporarily, as it is an RU (Runtime) table, that is, at runtime.
While this variable has its active lifecycle in the instance, it must appear in the database.

As soon as the instance leaves this scope where the variable was declared, or when the instance is finalized, the variable must be “deleted” from the table.

Hope I helped :smiley:
If I can help with anything else, I’m available.

William Robert Alves

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.