getVariable with throw error if null or does not exist?

I find i write a lot of boiler code and functions when doing getVariable
Is there a single function in camunda that allows you to do getVariable and apply conditions that ensure the variable exists and is not null?

something like execution.getVariable('myVarName', true) which true is the boolean that says that it must exist and cannot be null.

1 Like

I also quite like that idea - feature request?

@Niall any other scenarios you think could be covered?

  1. exists
  2. is not null
  3. is not empty string
  4. is a specific type?
  5. …?

I’m often in the same boat as you - i’ve got a bunch a of code dealing with null pointers when it would be much easier if the engine told me the variable exists. So for most of my use cases “not null” would do the trick.

Feature Request: https://app.camunda.com/jira/browse/CAM-8175

1 Like

Have you considered writing a utility function for this?