Accessing FormFields from Start Event

Hello All,

Please how can i access form field created in StartEvent in the next script task connected to it

Thanks

Hi,
Use exceution.getVariable(“variableName”)

1 Like

Hello,

Thanks too much @Alok0305 .

i tried exceution.getVariable(“variableName”) but it returns null with me

please find attached the flow xml

Simple_Camunda2.bpmn (2.8 KB)

Thanks too much

Hi,
Since you have used business key with start form that you’re not able to pass so its not able to fetch the values.

Simple_Camunda2.bpmn (2.8 KB)

If there is need of business key along with start form you go through below:

OR

I have the same basic issue. How to access the form fields defined in user task in end listener on current user task or the start listener of next activity

I have a User Task and define two fields on the Forms tab. I would then like to access the submitted values (submitted via the REST API ie. rest/engine/default/task/7a33e88a-9abd-11ea-a8d9-144f8af00e66/submit-form) in the end/start groovy listener inline script. But the fields do not show in execution.getVariables() map.

Do I need to go thru the execution.getProcessEngineServices().getTaskService()getVariables call, if so what ID from the execution do I use to get the Form Fields submitted for this user task?

I solved my issue by creating a Task Listener on the User Task for the Complete event type and in the groovy script setting the process instance variables by looping over the submitted form fields:

org.camunda.bpm.engine.FormService formService = task.execution.getProcessEngineServices().getFormService();
org.camunda.bpm.engine.form.TaskFormData taskFormData = formService.getTaskFormData(task.getId());
List<org.camunda.bpm.engine.form.FormField> fields =  taskFormData .getFormFields();

for(field in fields){
    task.execution.setVariable(field.getId(), field.getValue().getValue() );
    println "userValidationStartUserTaskComplete setVariable " + field.getId()+ " = " + field.getValue().getValue();
}