Expression to check if variable exist for gateway?

In a gateway I want to use an expression to check if a variable exist. How can I do that?

For example:

Gateway here use “PaymentAmount”. From Postman I never send “PaymentAmount” variable at start, so I want to handle this with an expression, not a script.

From, Unified Expression Language - The Java EE 5 Tutorial,
I have tried:
${not empty PaymentAmount}

and get response:
{

"type": "ProcessEngineException",

"message": "Unknown property used in expression: ${not empty PaymentAmount}. Cause: Cannot resolve identifier 'PaymentAmount'"

}

3 Likes

Not Empty checks whether the field has value or not. In your case the field itself doesn’t exists. So you got this error response from process engine service.

Unknown property used in expression: ${not empty PaymentAmount}. Cause: Cannot resolve identifier 'PaymentAmount'"

So can expression in gateway test if a field exist?

@Hula you can configure the expression like this:

${execution.hasVariable("PaymentAmount") == true}

Deploy this bpmn and test: varaiableCheck.bpmn (4.9 KB)

Test Case 1: Start 1 instance with variable PaymentAmount

Test Case 2: Start 1 instance without variable

3 Likes

Thanks, it’s working now :smiley: