Hello,
I have a multi-instanciated subprocess that returns informations about one Car at a time,
and I want to collect them for all the cars, in the root process.
So, the subprocess contains a business variable subCarDataItem, which is defined after the Business object carObject(attributes : id, make, model).
The root process contains 2 business variables :
- mainCarDataItem, defined after carObject
- wholeCarData, defined as a list of carObject
As defined in the call activity that runs the subprocess, in the "data to receive" section, subCarDataItem of the subprocess is assigned mainCarDataItem of the root process.
That means that mainCarDataItem only contains the data of the last iteration of the subprocess.
I've tried to add an operation in the call activity, that adds the content of mainCarDataItem into the list wholeCarData, but it doesn't work ("class BScript391$_run_closure2 cannot be cast to class org.bonitasoft.engine.bdm.Entity").
The operation is defined like this :
"wholeCarData takes the value of script()" :
and the script is :
def trtList = []
if (!wholeCarData.empty ) {
wholeCarData.each{ trtList.add({ currentline ->
def trtVar = new com.company.model.carObject()
trtVar.id = currentline.id
trtVar.make = currentline.make
trtVar.model = currentline.model
return trtVar
}(it))
}}
trtList.add({def trtVar = new com.company.model.carObject()
trtVar.id = mainCarDataItem.id
trtVar.make = mainCarDataItem.make
trtVar.model = mainCarDataItem.model
return trtVar
})
return trtList
What is wrong with that ?
Thank you in advance for your answer(s)
Regards,
Thierry.