cancel
Showing results for 
Search instead for 
Did you mean: 

Starting process with start form and process variables

pfeiffer
Champ in-the-making
Champ in-the-making
I'm having difficulties starting a process with a start form. I'm using formService.submitStartFormData and after that I'm setting the variables because they contain objects that I want to serialize and they cannot be passed in the same String value map of start form properties.

Of course if the variable is needed in the beginning of the flow, no variable is present yet and my flow crashes.

I could use runtimeService to start the workflow and put everything in that variable map there but then there is no proper start form handling and validation.

It seems that it should be possible to provide both process variables and Start Form properties before a process instance is actually started. Or is there another way to do this ?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
You could use a  listener on process instance start: check http://activiti.org/userguide/index.html#executionListeners

Or do you need to provide those objects yourself? I'm assuming not, and that those objects are built using the values in the form.

pfeiffer
Champ in-the-making
Champ in-the-making
Indeed I want to provide those objects myself.

The use case is that I want to associate every workflow with a resource in our own application. All the information about the resource is stored for every workflow at the start of the workflow and a lot of logic in the workflow needs that information. Some of those values that I want to store can be objects. If such a process has a start form for with I want also to send some start form properties, I don't have an option but to first send in the form properties and then send in my own variables, but this of course causes the flow to crash if some logic requires the variables before the thread is returned from the process and the variables are added.

Currently I was able to solve it by putting everything to string and no object process variables are needed, but I could be needing it in the future and when that happens I have a huge problem 🙂

It simply seems strange that it is not possible to start a process with a start form property map and a map of process variables that accept object values.

frederikherema1
Star Contributor
Star Contributor
Start-forms values are string-based deliberately to prevent an extra mapping-mechanism when exposed via rest. However, this does NOT prevent you of having typed objects in a start-form. Take a look at the existing form-property-types (see user guide). These can easily be extended to have string-property-values be converted to typed process-variables (Have a look at: org.activiti.explorer.form.UserFormType for an example on how to create one, and look in the /activiti-webapp-explorer2/src/main/webapp/WEB-INF/applicationContext.xml how to wire it.)

However, it seems like the thing you want to pass on isn't really something that belongs on a form, it's something that needs to be there in ALL of your processes, regardless of the values filled in. Then, as Joram pointed out, you can use execution-listener on the start of your process, setting the right Object instance as a variable, so you can use it throughout the process…