Use local and process variable in form

1
0
-1

Hi, i tried to use process variable in UI Form. To do this i used Bonita REST API for:
localVar ../API/bpm/activityVariable/{{task.id}}/localVar
processVar ../API/bpm/caseVariable/{{task.rootContainerId}}/processVar

[localVar] - Bonita process local variable (for task), of BDM Type.
[processVar] - Bonita process variable, the same type as above.

BDM Type
com.samplepackage.SampleObject
attr1 - string
attr2 - string
attr3 - int
attr4 - string

When i try to display variable value in form ({{[variable] | json }} i get this:
1. For process variable - processVar
{ "case_id": "25008", "name": "processVar", "description": "", "type": "com.samplepackage.SampleObject", "value": "com.samplepackage.SampleObject@2c34b9a7" }

  1. For local variable - localVar
    { "persistenceId": 3, "persistenceId_string": "3", "persistenceVersion": 0, "persistenceVersion_string": "0", "attr1": "value1", "attr2": "value2", "attr3": 999, "attr4": "test" }

And know is question - Why value of process var is representing by hash of object ("com.samplepackage.SampleObject@2c34b9a7") and how can i use it or convert to json ?.

1 answer

1
0
-1

Hello,

A process variable can but is not intended to store a Business Object instance of the BDM. Is there any specific reason why you want to use a process variable instead of a business variable?

Cheers,

Comments

Submitted by krzysztof.gemse... on Tue, 12/18/2018 - 14:20

Hi, thank you for answer.
Yes, i have process that is based (in first part of it) on process variable that is of type defined in BDM. Because i invoke a connectors and others operations, when this variable is fulfill i want to reassign it to BDM var and store in BDM Database, to have only clean data in it.
I understand that it is impossible to translate variable from hash to json ?.

Submitted by pierrick.voulet on Tue, 12/18/2018 - 20:22

You might want to use a dedicated library to do so. Two examples of what I used most of the time

Submitted by krzysztof.gemse... on Wed, 12/19/2018 - 09:38

In script (groovy) i don't have problem to use process variable, but it Form it's challenge.
JsonSlurper and Gson translate json->object / ob -> json, but this is not a case (when you use above library you have access to class of object you are parsing, in form you don't have this information, to form you send only json - in process var object hash).
I suppose that JS/Angular/Bonita don't have any web library to translate hash of process variable to json in view ?.

Ok so summarizing, to use process variable in Form i need first, rewrite it to local and use local in form, get contract back and reassign it to process var back ?.

Submitted by pierrick.voulet on Wed, 12/19/2018 - 13:48

From what I understand you are trying to retrieve the value of a process variable value (BDM typed) from your UI (JS).

Your design is not common, the best practice is to use a business variable instead of a process variable and to use the dedicated REST API to request the data from your UI (JS).

I advise you to follow the Bonita Camp available publicly on YouTube to learn more about this. If you do not have the time to follow the entire session, you could check the exercise corrections from the related GitHub project as it will give you good examples of what I am talking about.

Notifications