How to display business object that has multiples of another business object as attributs in a table widget?

1
0
-1

Hey, everyone, I'm relatively new to Bonitasoft (Community-7.8.2). So, sorry if this question seems dumb.

I've been having trouble getting attributes to be displayed in a table widget.
My business object "Analyse" contains multiples of this other business object called "DemandeAnalyste" in a composition relationship.
From my understanding, this makes the BO "Analyse" I'm trying to populate the table with an array of array and that's why my attempt has failed.

I have looked around in the forum as well as the documentation and tried several options (none of which were fruitful since I'm posting this question)
In one of the answers to a similar question the forum, there was a mention of converting the array to array of objects using javascript. There's no followup to this solution and I did some research to figure it out on my own and was unsuccessful.

I've hit a brick wall and could use some help from the community.

Thanks in advance, Reem.

1 answer

1
+1
-1
This one is the BEST answer!

A table widget cannot be inserted inside another table widget. So it does not seems appropriate to use table widget to display data of an object with the associated objects (with the composition relation).

Instead I would recommend to use "container" widget. You can add containers inside containers. I create an example that display invoices. An Invoice is a composition of several InvoiceLine and an InvoiceLine as a product attribute that is an aggregation of a Product object.

Comments

Submitted by rhammami_1394243 on Tue, 05/14/2019 - 14:45

Thank you so much for your reply. It's quite insightful. However, when I downloaded the example and tried to import it in Bonita, an error occurred: It said that .bos file is not valid.

Submitted by antoine.mottier on Tue, 05/14/2019 - 14:51

I create my example using Bonita Studio 7.8.4. You should use this version (or later) to import it.

Submitted by rhammami_1394243 on Tue, 05/14/2019 - 15:55

Downloaded the 7.8.4 version and successfully imported the .bos.
Thank you again for both the solution and for the quick the responses.
I was going through the example and I have a couple of questions:
in the examplePageInvoices page, the invoiceLinesForInvoiceWithPersistenceId variable has this API URL for a value: ../API/bdm/businessData/com.company.model.Invoice?q=findByPersistenceId&p=0&c=10&f=perstenceId%3D1
What does the perstenceId%3D1 stand for?
When I call this API in my own forum, do I also put perstenceId%3D1 as value for the f parameter?

Submitted by antoine.mottier on Wed, 05/15/2019 - 09:26

The parameter f= is used in this situation to define the BDM query input parameter value. perstenceId is the name of the parameter as defined in the BDM query, %3D is the = character URL encoded and 1 is a static value for the persistence id of the business object I was looking for in my quick test. Persistence id is a unique id automatically assign by Bonita to each individual business object.

Submitted by rhammami_1394243 on Wed, 05/15/2019 - 10:28

Got it. Is there a way to get the perstenceId dynamically to retrieve the business of object in the current case?
'Cause in my process, 3 actors insert values into the "analyse" business object then in the next step (meaning after they've finished) 2 actors view their input (at first I wanted it to be in a table but as you very clearly explained that is not possible) and input value into a different business object that's called "sort" with a similar structure to "analyse." After that another actor receives a task for final review, views both the content of "analyse" and "sort" and makes the final decision of rejecting or accepting.
When I excute this process, and go to the h2, I see the values getting stored correctly with the multiple attributs getting the correct PID. It works fine. I really hope therer's a way to get the perstenceId dynamically.

Submitted by antoine.mottier on Wed, 05/15/2019 - 15:35

When being displayed, a "task form" or a "process overview form" are always associated with a process instance (instantiation form is associated with a process definition and a page is not associated with any process definition or instance).

This association between a form and a process instance (when displaying the form) means that from the form you can get process instance information including the reference to business variables declared in the process definition. For example, if you have a variable named myInvoice of type com.company.model.Invoice declared in your process definition, you can access its value by calling the following REST API URL: ../{{context.myInvoice_ref.link}} Usage of double curly brace means that it will be replaced by the variable value. context is a variable available by default when you create a form from the Studio.

Submitted by rhammami_1394243 on Wed, 05/15/2019 - 16:27

Thank you so much for explaining things for me so well.

I applied what you just told me and still nada.
Added a variable named analyse with the value ..//{{context.analyse_ref.link}}
I put a container and in the collections' value analyse.
And inside that container another container and it's collections' value I put the (multiple) object populating analyse: $item.demandeAnalyste
Followed your example, by putting each of attributes in a disabled input widget.
Ran the process and the only thing that appeared was the Analyse: {{analyse | json}} I put in the top.
I tried again by modifying the value of the collections': instead of demandeAnalyste I put $item.analyse.demandeAnalyste.
Ran it and there was no result.
Tried to modify the value of the attributes next: instead of directly putting the attribute I put the object first followed by a period (eg. appreciation became $item.demandeAnalyste.appreciation | in a next attempt $item.analyse.demandeAnalyste.appreciation)
I really don't know what I'm doing wrong here.

Submitted by antoine.mottier on Wed, 05/15/2019 - 16:38

Can you export your process definition, BDM, forms... from the Studio in a .bos file and share this using Google Drive, Dropbox...?

Thanks

Submitted by rhammami_1394243 on Wed, 05/15/2019 - 16:52

A little heads-up: it's quite messy and it's in French.
The part I'm trying to figure out is in the form called "membre" mapped to the task "donner avis + commentaire"
https://drive.google.com/file/d/1FA607KNjvXJa1kGU0Bub89SFMJZWScE4/view?u...

Submitted by antoine.mottier on Wed, 05/15/2019 - 18:28

I create a basic process that declare one business variable using your data type Analyse and associate to the single task of the process your existing form named membre. When running this process (that create a new Analyse with only the description set) I can see in the form that analyse information is correctly fetched (i.e. I can view the raw JSON displayed in the form).

The issue is actually in the definition of your form. You provide the analyse form variable as a collection for the top container widget, but analyse value is actually a single JSON object (the word "collection" in the container configuration refer to an array). For example, the attribute demandeAnalyste of the Analyse object is an array because the definition of the attribute has the "multiple" option checked.

The solution would be to modify your form or set your process business variable as multiple (this will create a java.util.List).

Submitted by rhammami_1394243 on Wed, 05/15/2019 - 18:35

How do you suggest I modify the form?

Submitted by antoine.mottier on Wed, 05/15/2019 - 20:01

If you have a single Analyze object then don't associate the form variable analyse to the container widget: remove it from the collections property.

Submitted by rhammami_1394243 on Wed, 05/15/2019 - 20:21

Yup, it worked now. Thank you so fricking much for bearing with me. I hope I didn't annoy you so much with my dumb questions. (they surely feel dumb to me.)

Submitted by maouachria on Tue, 07/23/2019 - 19:17

Hi;
I create a BDM with business objects, each of them has multiples others business object as attributs.
for each task in process, i assigned a form that was create from contrat, this contrat contains these business objetcts;
After running this process, there are no data in H2 data base? also, i can not display this data when i use:
../{{context.adtaA04_ref.link}} ?

please, I do not know where is the problem?

Submitted by antoine.mottier on Wed, 07/24/2019 - 09:34

@maouachria this comment does not seems to be related to this question. Can you create a new question?

Also in your question if you can share your .bos file that can be helpful.

Thanks

Submitted by maouachria on Thu, 08/01/2019 - 12:12
Submitted by maouachria on Thu, 08/01/2019 - 12:10

please sir @Antoine, have you any solution or suggetion for my question ?

Submitted by antoine.mottier on Mon, 08/12/2019 - 17:28

I will try to answer on the new question you create.

Notifications