BPM7 - How to pass variable in business model instance to a database connector

1
+1
-1

Update: See my last comment to skip to part of the answer.

I have tried many ways of doing this but not able to find any documentation or videos out there. Maybe the new version is to need.

How do we pass data contained in our process instance of a business model to the connector (Postgresql) SQL query? I have tried several ways without any success:

INSERT INTO "MyTable" ("Name") VALUES ('${varMyBusinessModel.Name}');

INSERT INTO "MyTable" ("Name") VALUES ('${{varMyBusinessModel.Name}}');

INSERT INTO "MyTable" ("Name") VALUES (${varMyBusinessModel.Name});

INSERT INTO "MyTable" ("Name") VALUES ({{varMyBusinessModel.Name}});

INSERT INTO "MyTable" ("Name") VALUES (varMyBusinessModel.Name);

Comments

Submitted by BrianPeal on Wed, 06/24/2015 - 04:09

So I have figured out that I have to set a process variable first to be able to access it from SQL and the correct format is ${variable}

however,

it is not clear how to pass a business object instance into the SQL and access fields. For my scenario:

A initiator form with a single text field -> to a contract with a single text field -> to a service task connector out -> to a Postgresql database

Submitted by BrianPeal on Wed, 06/24/2015 - 14:52

OK the correct format to pass a process variable to the SQL is

INSERT INTO "MyTable" ("Name") VALUES ('${myProcessVariable}');

Note the placement of the quotes as my database column is a string data type. You can also use the Ctrl+Space to see a list of the process variable available to the SQL.

HOWEVER,

I still cannot find a way to get a reference to the business object instance value to populate into the SQL. Any ideas?

Submitted by david.doumeche.itk on Wed, 06/24/2015 - 15:00

Brian, - global variables are available in every script of the process - local variables are avalaible only in the current task - you affect to those variables the output of form processing in the tab Data > Ouput operation

  • you may then use those variables in your Postgresql connector :
INSERT INTO "MyTable" ("Name") VALUES ('${varMyBusinessModel.Name}')

or

INSERT INTO "MyTable" ("Name") VALUES ('${myPrimitiveVariable}')

To get confident with groovy, I advise you to install Eclipse + grEclipse : https://github.com/groovy/groovy-eclipse/wiki

Submitted by BrianPeal on Thu, 06/25/2015 - 00:41

Thanks for the help.

I used the command as you describe but it puts the value of "${varMyBusinessModel.Name}" literally into the database. The command works for primitive variables though and as a text ("test"). I can map an operation to set the primitive variable with the value of the business object instance and use the primitive value in the SQL with no issue.

When I hit Ctrl+Space, the business object instance does not appear in the list, only the primitive variable. Is the business object instance supposed to appear in this list?

Submitted by david.doumeche.itk on Thu, 06/25/2015 - 09:36

if ${varMyBusinessModel.Name} appear litteraly in database, it means than groovy interpreter can't locate a corresponding variable instance. Did you declare varMyBusinessModel as a global variable in Data tab ? Or as a local variable ?

Submitted by BrianPeal on Thu, 06/25/2015 - 15:21

It is in the pool variables. This seems like the only option for a business model initiated as a variable.

Note: I was able to set a default value in my business model variable, then set a pool process variable to the value of the business model variable, then use the process variable in SQL/connector with no issue. So the root issue is how to access the business model variable from SQL/connector. Could this be a bug in version 7? Does this work for anyone else?

Submitted by david.doumeche.itk on Thu, 06/25/2015 - 15:32

I doubt it, but who know Can you try it with an older version of Bonita bpm like the 6.5.0 ?

Submitted by BrianPeal on Thu, 06/25/2015 - 15:34

I thought business models were not part of the 6.5 community version?

Submitted by david.doumeche.itk on Thu, 06/25/2015 - 15:37

I am sorry, I dont know the Business Model mode and this is the community forum.

Maybe you should ask at bonitasoft support team if you have the non-free version ?

Submitted by BrianPeal on Thu, 06/25/2015 - 18:29

I do have the community version of 7.0.0 which includes BDM and contracts. So is this the correct forum?

2 answers

1
+1
-1

This has been confirmed as a bug and there is a workaround provided by Philippe here. THANKS Philippe!!

1
0
-1

I have the same problem and it is solved with this solution: Bug Thank you Brian and Philippe for your help!!!

We need more documentation, tutorials, examples, and help BonitaBPM 7!!

Notifications