Set new process variable depending on Order data

Hi,

within a process I already have the Order data as a JSON-Object. See attached reduced example.
Now the requirement is to set a process variable with a value depending on the postiitons of the order.
If in one of the lines an item with an id starting with ‘EP’ is used, set variable x to value 1.
Else if there is any position with isMakeToOrder == true, then set variable x to value 2.
Else set variable x to value 3.
Based on the attached eaxmple in this case the result should be variable x = 2.

This is probably something for a script task, something I did not use so far.
Any hints or example references welcome.

Regards, Frank

Auftrag_mit_Details_reduziert.json (899 Bytes)

Hi Frank,

this sound like a use case for a script or DMN.

Since I prefer FEEL, this script could look like:

{
  startsWithEP: some item in positions.items satisfies starts with(item.id, "EP"),  
  isMakeToOrder: some position in positions satisfies position.isMakeToOrder = true,
  result: if (startsWithEP) then 1 else if (isMakeToOrder) then 2 else 3 
}

Read more about scripting with FEEL in the blog post.

If you prefer, this could be also part of a decision table.

Best regards,
Philipp