Want to discuss a use-case

Hi,

I wanted to discuss a Use-Case as per our project in which we have a start process which starts the process-instance. WE are not using an embedded form or Camunda web applications and the process the we are using is that we have a form and have a submit button on it. On click of the button following things happen:

  1. form values get saved in database
  2. process instance gets started(Rest API call in the Java servlet)
    Query -> I need to store a variable in the not-embedded form as a process variable to be used in the DMN.
    Confusion -> Shall I make the servlet class implement Java Delegate and use : execution.setVariable(“region”, region); to set the process instance. If yes, then when will this method be called. I tried implementing the method like this :
    public void execute(DelegateExecution execution) throws Exception {
    execution.setVariable(“region”, region);
    System.out.println(execution.getVariable(“region”));
    }

Query -> Would DMN automatically take “region” variable as input in the bpmn? If not then what should be done?

Hi @AakankshaTej,

I am not sure I understand your questions correctly. What I understood so far is:

  • you have a process deployed in the engine
  • you have externally implemented web application which submits form to a servlet
  • you have a servlet that has to start process instance with variables set.
  • you would like to start process over REST API

is that correct?
Your question is: how to set variable to a started process instance?

To set variables over REST API you could:

  • pass them while starting process instance [1], [2]
  • set them after process instance is started [3]

I have to admit, i did not fully understand query DMN question, may be you could explain in a bit more detail.

Does that help you?
Askar

I got my solution thanks.

I needed to ask one more thing - Do the process variables persist in the entire process instance or all BPMN tasks? Or are they only accessible in the next connected task?

Hi @AakankshaTej,

variables are stored in specific scope you can read about it more here [1].

Does that help?
Askar

That does answer my question -
A variable that is defined on a parent scope is accessible in every child scope unless a child scope defines a variable of the same name.

Thanks

Hi,

You shared two links to pass variables while starting the process instance which I implemented successfully. Now I want to send a process variable from my custom application (on click of a button) to a process definition, during the current execution of the bpmn flow so it can be used in an exclusive gateway. I tried following the second link you shared but that is for binary data. So I was unable to understand the same. Can you help me with this?