(solved) Initialize Business variable using process variable value


can i initialize a property of a business varible using the value of a process valiable?

The above code in the groovy script throws the exception "No contract data found named: aProcessVar"
def myvar = new myBusinessObj()
myvar.aBusinessVar = apiAccessor.getProcessAPI()
.getProcessInputValueAfterInitialization(processInstanceId, "aProcessVar");
return myvar

Also on a connector (input or output) i cannot update the value of a variable:


Submitted by antoine.mottier on Mon, 01/29/2018 - 10:24

According to your code example your are not only updating the business object attribute but you are actually creating a new instance of this business object by calling the new operator.

Can you clarify when and how the process variable is initialized and also when is the business variable initialize and when do you want to update it? (by when I mean in the default value of the variable, in an operation, in connector output...).

Note that sharing your process (exported as a .bos file) can help to identify a solution.

Submitted by mtsiak_1358773 on Wed, 01/31/2018 - 07:55

@antoine.mottier i am editing the default value in the Edit Business Variable window. That is why i am uning new. Any suggestions?

Submitted by antoine.mottier on Wed, 01/31/2018 - 09:55

Can you share your process file? I need to understand a little bit what you are trying to achieve in order to provide appropriate help.

Submitted by tim_34 on Wed, 02/07/2018 - 19:21

While I understand that more info might make diagnosis easier giving us some, any, examples would help get over the hurdles.

I'm getting frustrated failing to do really simple things. I want to put the results of a script into a field in a business variable - but the GUI will only let me have a "whole" business object. I just can't see how to get it to set a single field.

Submitted by antoine.mottier on Wed, 02/07/2018 - 22:06

To update a business variable attribute using the output of a script, in the operation definition, click on the "Takes value of" link and in the drop down list select "Use a Java method" and select the appropriate "set" method to update the attribute you want.

I create an example with a simple BDM that you can download and run: https://www.dropbox.com/s/4iptla2x7rk5ha8/DemoUpdateBusinessVariableAttr...

Submitted by mtsiak_1358773 on Thu, 02/08/2018 - 08:40

@antoine.mottier i cannot import your bos file. It says: this BOS archive is not valid.

I am also sending a simple bos file. The idea is to initialize the business variable empBusinessVariable.cn with the user's name, and the empBusinessVariable.givenName with the aprocessVar, before Step1. And those values to be shown/ kept also at step2.

Thank you for your interest.

Submitted by antoine.mottier on Thu, 02/08/2018 - 09:17

My example was build with Bonita Studio 7.6.2, so updating your installation might allow you to import the example.

Submitted by mtsiak_1358773 on Fri, 02/09/2018 - 13:24

@antoine.mottier problem solved. I am not using InstatiationForm. Instead, after start event i have created a service task (st1) and then a user task (ut1). In st1 i have created a groovy connector where i create a new object (obj1) of my BusinessVariable type. Then using the setters, I set the obj's property with my processVariable value (in this script it should have been instatiated). Finaly i return the obj1. The output of the connector is used to initialize (initialize with) the BusinessVariable.
Thank you for your time.

No answers yet.