I need to get the persistence id and save it in a different attribute/property of the BDM. The business variable has been defined in the pool lane so it has a init script in the default value. I tried this but when i checked in the h2 object, id column is still null: The business variable has been used under Instantiation form
import com.model.bdm.MyApps
def myapp= new com.model.bdm.MyApps()
myapp.id = myapp.persistenceId
myapp.name = mayappInput?.name
myapp.address= mayappInput?.address
return myapp
How can i save it on a different attribute/column?
Why are you trying to save Persistenceid. It is managed by system and cannot be manipulated by user.
Do you mean processInstanceId ?? ProcessInstanceId is the case id
You can create a Unique PK for your table and Increment it when a new row is inserted. You can then use that Key as a Identifier.
Regards
I thought that on the initialization, ProcessInstanceId has been generated and available.
I just need to save it on another column. I change the approach as you mentioned to have a unique PK for which i use processInstanceId.
You can use ProcessInstanceId. It is a unique value. ProcessInstanceId can be saved in your database table.
ProcessInstanceId is the same as CaseId in BPM Portal.
You can save ProcessInstanceId as soon as the case is started.
PersistenceId is different and should not be used. Persistenceid is maintained by System .
For my use case , I create a column called requestId. I increment RequestId +1 for every request.
I have use a JPQL to get the max Requestid and then MaxRequestId()+1