To check if a string value exists within an array of string within the decision gateway

Hi All,

I want to know if we can set a list of string values during the process initiation from springboot and once done, can we check if a string value exists within the list at the modeler gateway.

consider below example,
stringVariableList = [“apple”,“orange”,mango"]; ← Can we set something like this in java?

now within the modeler gateway can I check stringVariableList.contains(“apple”) → go to task 1, stringVariableList.contains(“orange”) → go to task 2, else task 3. If yes, pls let me the approach to achieve this.

@syedkp It’s possible to store variable as list in camunda.

stringVariableList = [“apple”,“orange”,”mango”]; 

stringVariableList.contains(“apple”) → go to task 1, stringVariableList.contains(“orange”) → go to task 2, else task 3
  • In this case, if you want to create tasks only for a few specific items, then checking the condition using XOR gateway would be perfect. Conditions can be configured in the outgoing sequence flows from the XOR Gateway.

  • If you want to create a task for each items in the list then a multi-instance task would be perfect for this use case.

1 Like

@aravindhrs - Thanks for your response. I wanted to know the syntax. like simple boolean I used to check this way #{isAppleAvailable==true} but how will the above check be validated? Is it this way? #{stringVariableList.contains(“apple”)==true}. Please share some example for my better understanding. TIA.

This will work

2 Likes

@aravindhrs - Thanks once again. I will test and let you know.

@aravindhrs - This worked, thanks. Do you know how will the condition be set in camunda 8 and I dont see the options as expression or script.
I tried this way, = stringVariableList.contains(“apple”) but it failed saying its returning java.lang.String instead of java.lang.boolean.

Hi @syedkp,

Camunda 8 uses FEEL expression where Camunda 7 uses JUEL.

You can use the list contains function on lists: List functions | Camunda Platform 8 Docs

Hope this helps, Ingo

1 Like

Thanks @Ingo_Richtsmeier. I will check the link and give a try.