I’ve recently started working with Flowable. I encountered a problem with using multi-instance in UserTask.
I have a java class called Reservation, which has a Set of ReservationItem objects as a field. Reservation is persisted together with its items.
Reservation object is passed as a process variable when I startProcessInstanceByKey(..). During the runtime, I wish to create a multi-instance, parallel, user tasks, one for each ReservationItem.
My problem is as follows. From what I understand from the flowable website, I can pass a process variable, yet I don’t know how to extract ReservationItems from Reservation process variable.
Thank You for the reply - I tried both {reservation.getReservationItems()} and reservation.reservationItems, which gave me:
Variable '{reservation.getReservationItems()}' was not found org.flowable.common.engine.api.FlowableIllegalArgumentException:
What I forgot to include in my initial problem’s description, yet now I think it may be relevant, is the fact that reservation is a process variable of my “main” process, whereas creating multi instance user tasks happens in call activity.
My call activity has a property “Inherit variables in sub process” set to true, a diagram it refers to is simply start event -> user task -> end event, in user task I tried aforementioned expressions. Does that change the perspective somehow? Perhaps should I handle this case differently?
Do note that using serialized java objects is not a good practice as it tends to make the database size large.
Would You be so kind and elaborate slightly on this?
In that case, it should be available in the child process instance. Can you print it out (e.g. with a groovy script task) to check whether it’s actually there?
Using java objects, things are serialized to bytes. Databases don’t optimally store bytes. Using textual formats such as JSON work way better for databases.
Using java objects, things are serialized to bytes. Databases don’t optimally store bytes. Using textual formats such as JSON work way better for databases.
Thank you, I will try to work on it.
In that case, it should be available in the child process instance. Can you print it out (e.g. with a groovy script task) to check whether it’s actually there?
I did as You asked, I am able to retrieve a variable using a custom delegate/task listener, I can obtain a proper ID, yet when it comes to retrieving ReservationItems, I get empty collection “”. I dug a little deeper, it seems that when hibernate makes a query to the database to obtain ReservationItems, the ID is missing, namely, the query looks like this: SELECT .... FROM ... WHERE reservationID=?
that would explain an empty collection, but now I don’t know if it is hibernate or flowable related. Should you have any clue, I’d glad to hear it, perhaps it is something flowable does underneath the surface, or perhaps it is my problem with the hibernate
I figured out my issues with hibernate from the post above. I also moved to parallelism to the call activity and left subprocess underneath as a: start event → user task → end event.
In my multi instance call activity, I set collection to be {reservation.getReservationItems()}, which raises an error, as above. Does anyone know the solution for this perhaps? reservation.reservationItems also doesn’t work
getter is set with Lombok annotation; is it possible that flowable can’t see this?
Also, please correct me if I’m wrong: if I set the multi instance element variable to “item” and check “inherit variables in sub process”, I should be able to retrieve “item” in the subprocess as a variable, right?