How to use variable in a form

Hello evrybody,
I would like to do a simple process
immagine

where the user inserts a string into a form (Embedded or Auto generated) in the Start Event. I would like to store this string in a variable and use it in a Java Listener for processing.
It’s possible to do it ?
I currently get a “null” value

Thanks
O.

@oronzo_lezzi Form variables from the start event are usually we can save as process variables and can be accessible in any of the activity if the variable scope is global visibility across the process.

Thank you @aravindhrs for your answer. Let me explain better:
I have this form in startevent

   <div class="form-group">
    <label for="dipendente">Nome del dipendente</label>
    <input class="form-control" cam-variable-type="String" cam-variable-name="dipendente" name="ff_dipendente" />
  </div>

I’m trying to use this Java code for delegate

package org.camunda.bpm.getstarted.loanapproval;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
public class startEvent  implements JavaDelegate {

 public void execute(DelegateExecution execution) throws Exception {

	 String dipendente= (String)execution.getVariable("dipendente");
	 String idProcesso=(String)execution.getProcessInstanceId();
	  
	 System.out.println("la variabile dipendente è :" +dipendente);
	 System.out.println("la variabile idProcesso è :" +idProcesso);

     }

}

I need to retrieve the value of variable in Delegate Task.
It is possible ?
Can you help me ?
Thanks
O.

When I execute the process the variable “dipendente” is NULL

@oronzo_lezzi In the user task “verifica”, did you configured the java delegate in the execution listener or task listener?

Hello ,
I have configured the Execution Listener in Start Event
is it correct ?

@oronzo_lezzi You can’t access form variables of start event in the execution listener of start event itself.

Because form variables are not persisted at this point of time.

Maybe you can try marking the start event as async: Before = true . If it not works, change the listener to the event type= end in the start event and also keep asynBefore=true

2 Likes

Thank you very much, it works