How to enforce variable requirement in sub-process?

Hi,

I have a sub process, and it requires certain variables to be present. how can we enforce that those variables are required? Any ideas?

I am thinking that we might have error flow in the sub process itself which triggers if we do not find an variable. but not sure about other alternatives.

Thanks

1 Like

Ways to enforce it - you could put a FEEL expression on the subprocess that uses all the required variables, and causes it to raise an incident when one is not present.

You could have a worker with an API schema validator on the payload that throws when required variables are not present.

Those two methods result in an incident, rather than an error flow. With the second one, you could throw a BPMN error from the worker.

In addition to Josh’s comment, you could define the FEEL expressions, for example, as input mappings on the call activity (e.g. by mappings the variable to itself a -> = a), or as output mappings on the start event of the subprocess.

Hmm if an error leads to incident then isn’t it the process will dangling in a state where the error happened so in this case in the sub process? and then needs manual intervention ? Or if you could explain a bit more on the flow how it will go from first time error to how it gets resolved

Thanks

Yes. If an input/output mapping can’t be applied then an incident is created. Usually, an operator would see the incident and fix the problem manually, for example, by using Operate.

How should the process handle the situation?
Please share more about your use case and your ideas :slight_smile:

Hmm yeah. I guess it needs to be custom somehow then. So what I am expecting is that subprocess responds with some error state to the main process and then main process takes a different route depending on the error.

Is that possible ?

Yes. Error events could be a good choice: Error events | Camunda Cloud Docs