Changing values in BDO

So moving along with my learning of Bonita.

I want to change the value of an attribute in a specific BDO record. Let me explain.

Say I have have a BDO describing Invoices.

All Invoices BDO

  • Invoice 001
    – Date
    – Client
    – Purchased Items
    – Paid Status (Yes or No)
  • Invoice 001
    – Date
    … etc.

At first the Paid Status will always be No(false). As soon as I have the payment, I want to be able to change that value to Yes (true).

How do I go about changing the value for that specific invoice? Is it a groovy script or is there a way to edit it directly through the UI?

Thanks!!

on the return from a form can’t you in the operations tab just do a BDM.setVariable(value)?

This is how it’s done in the getting started tutorial (managers review section)

regards
Seán

PS: If this reply answers your question, please mark a resolved.

Pool variables: data to be used throughout the entire pool. It exists as a temporary object while the engine server is running.

Almost → Pool variables: data to be used throughout the entire pool. It exists as a temporary object for a CASE.

So for example User1 starts the process and generates Case1 with PoolVariables1; when User2 starts the process and generates Case2 he will get PoolVariables2. PoolVariables2 are only related to Case2 and are totally separate from PoolVariables1.

Local variable: exactly like the pool variable, with the only difference that the scope of this variable is limited to a specific task.

Correct

BDO: Is data that is exported during the execution of the process and stored on an external database. This data can only be looked at through the REST API, or the Java API but it can only be modified while on an active instance/process.

Sort of, here is my reading:
BDM is a model of the data,
BDO are instances of the BDM

BDOs are created and populated during the execution of a process case. Bonita stores the data in a database as a function of the system only and they will persist (be available) as long as they are not deleted. They can be accessed via the queries in the BDM.

External Data is Database data, used as required for records of information rather than a BDO. A record could be considered as an individual BDO and vice-versa. For example the BDO statement SQL select name from BDO where id=1 is the same as from external database SQL select name from mySQL where id=1.

BDO’s take away the need for connection parameters etc. unlike SQL where you need to connect, read, disconnect etc… These can be quite heavy on performance and when you have 10,000 users opening case all the time etc…BDO works well in this case.

Now then what is a BDO? Good question.

A customer is a BDO but is the Customers address a BDO? Depends on context.

To the inland revenue a customer is a BDO and addess is simply an attribute of the customer.

To the land registry the address is the BDO and the customer (owner) is simply an attribute of the address.

Now how to use BDO’s (the CRUD)

When CREATING a new Customer.... Start process/case Create BDO Process initializes Business Variables (BDO) Enter data in form/page Map data (Using the CONTRACT - Automatic) Contract saves the Data to BDO End case/process When READING a Customer.... Start process/case Read BDO Display on Form (using Contract) fields ARE readonly End case/process When UPDATING the Customer....version 1 - NO HISTORY Start process/case Read BDO Display on Form (using Contract) fields are NOT readonly Update data in form/page Map data (Using the CONTRACT - Automatic) Contract saves the Data to BDO End case/process When UPDATING the Customer....version 2 - WITH HISTORY Start process/case Create newBDO Read oldBDO Copy data from oldBDO to newBDO Display on Form (using Contract) fields are NOT readonly Update data in form/page Map data (Using the CONTRACT - Automatic) Contract saves the Data to BDO End case/process

Doing Update 1 will return only 1 record (BDO) when you do Select customer from customerBDO where id=2 however doing Update 2 will return X records for the number of times a customer has been changed when you do the same select.

This is shown in the Application Page of the Getting Started Tutorial where we return lots of instances of the travel requests…

The question here is do you need to keep HISTORY for the Auditors of changes to data records…some do, some don’t. Do you need to know the when and who changed the status of a customer from Living to Deceased? In today’s world you nearly have to record everything and this where where I think BDO Update version 2 works extremely well.

Then I have the following questions:

How do I sort the data from the new variable to retrieve a specific record?

The BDO’s have their own queries to which you can also add your own customized versions (as in the Getting Started Tutorial).

I would assume once I do that I could simply use a set constructor and change the data.

Yes as per the Managers’ Review in the Getting Started Tutorial

Once I make the change how do I make the change in the actual database?

You can use the SET as discussed above.

Would I be creating new records? Replacing the entire BDO?

Depends as per Update version 1 and Update version 2

I don’t know if my doubts make sense.

Yep, it does…and I hope my answers also do,

regards
Seán

PS: If this reply answers your question, please mark a resolved.

Hi,
And this may assist you to get a deeper knowledge about the bdm, http://community.bonitasoft.com/node/22351#node-22355
@Sean, credits for you.

Regards,
Vivek

Seán, I’ll look into the example. From what I remember this is during the same process instance. I’m looking for a solution where if I start a new instance, say another day. So the information is not part of a specific, continuous process. In other words, in this example payment isn’t left as an open process.

I’ll let you know if that’s the solution I’m looking for. Thanks!

@Seán, I’ve looked at the example from the documentation. From what I understand, the Vacation Request and Review is done in one process. The manager doesn’t select the Vacation Request he will review but rather a new request generates a new instance of the process. Therefore, as I understand it, the data in that particular request is not finalized until the manager has reviewed the request and given his/her approval or refusal.

I may need to rethink hoy I’ve designed my process, but the analagous example for what I’m trying to do is that there is one standalone process to request the vacation. Then the manager in a standalone iterative process chooses which request he wants to review. Therefore, the Request information has already been entered into the BDO, then the manager must locate the specific request in the database and change the status value from pending to either approved or refused and “update” the BDO.

This may not make sense for this specific vacation request, but say we added to this process. The manager reviews the request and refuses it because of days the employee can’t leave. Rather than that data being discarded and a new, edited request be created, the employee could simply change the dates and resend the request. In this case, the employee edits the the date and the manager changes the value from refused to approved. How would you script those changes?

In essence, I want to write a script that directly selects the specific object in the BDO database and changes only the fields I want. Is that possible? Maybe what I need is a direct connector to the BDM database?

I hope this makes sense!

Thank you for your help thus far! I really appreciate it!

I think you’re close.

The GST was only to guide you to the though of changing the process.

I think you need to do this:

In Invoice Diagram

  1. Create an invoice pool (as per the GST Instantiation form) and simply end. The BDO will be created.
  2. Create a Review pool in which you select all invoice = pending and display in a table with hyperlink(s), and end.
  3. Create an Edit pool to display the chosen invoice (review table hyperlink) and then on return (if it has changed) do the update using BDO.setField(newData) in the Operations tab.
  4. Create an Approve pool to display the chosen invoice (review table hyperlink) and then on return (if it has changed) do the update using BDO.setField(newData) in the Operations tab.

The users of the various pools should be defined by the Actors so assigned…
The Review pool could have two links one to edit and one to approve…

regards
Seán

Seán, thank you for your help. I guess I’m asking a broader question rather than a solution to a specific case or example. Unfortunately, I’m new to application/programming design.

In essence, I have data that has been written during a finished process. I want to go back and change a specific attribute on a specific record. Perhaps a better example is changing a customers address in the database. Does that make sense?

The way I visualize the data used in Bonita is like this:

Pool variables: data to be used throughout the entire pool. It exists as a temporary object while the engine server is running.

Local variable: exactly like the pool variable, with the only difference that the scope of this variable is limited to a specific task.

BDO: Is data that is exported during the execution of the process and stored on an external database. This data can only be looked at through the REST API, or the Java API but it can only be modified while on an active instance/process.

Maybe I don’t understand how data is written to the BDO database. This is what I understand:

  1. Process initializes Business Variables
  2. Enter data in form/page
  3. Map data onto array (using set constructors)
  4. For each record add onto List Array.
  5. On return command data is saved into BDO database
    Once the process has been finished and the case/instance has been closed all context information is lost.

Say I want to make any changes to the data in a new, non-sequential, distinct process. I can only see how to do the following:

  1. Create a new Business Variable
  2. Get the data from the database and, with it, initialize the new variable.

Then I have the following questions:

  • How do I sort the data from the new variable to retrieve a specific record? I would assume once I do that I could simply use a set constructor and change the data.
  • Once I make the change how do I make the change in the actual database? Would I be creating new records? Replacing the entire BDO?

I don’t know if my doubts make sense.

Thanks for all your help!

Thank you very much Seán for your time and your answer! Lot’s of material to understand. I will see if I can make the changes to the update process and I will let you know. If it works I will mark as resolved!

Seán, here is an example I have been working to try to get the code right. LINK It is very simple. To begin with I add inputs to two bdo and in the second task I try to edit a selected item. I can’t seem to get the context api to work.

Thanks for your help. I’ll keep working on this in the mean time.