How to link a modifiable simple collection with an attribute in the database?

1
0
-1

Hi all,

In my UI I would like to create a list of stats (mean, min, max) so the user can remove them or add a customize stat. I followed this Bonita documentation to create a modifiable simple collection:

https://documentation.bonitasoft.com/bonita/7.11/repeat-a-container-for-...

What I have is:

  • A business model called TestChecklist with an attribute named checklist (multiple string).
  • In the UI I create a JSON variable named stats_lists with the flowing array: ["p75", "mean", "min", "max"]
  • In the UI there is a container which has stats_list in the Collection. Inside this container there is an input and a button widget. The input has a value of $item and the button has a Remove from collection Action, a Collection value of $collection, a Remove Item and an $item in Item to remove.
  • Outside the previous container there is another button with an Add to collection Action, the stats_list as Collection and Last in Add.
  • The formOutput looks like:
    if( $data.testChecklist ){
    return {
    //map testChecklist variable to expected task contract input
    testChecklistInput: {
    checklist: $data.testChecklist.checklist !== undefined ? $data.testChecklist.checklist : null
    }
    }
    }
  • When I try to submit the process I get the following error:
    Debug message
    Error while validating expected inputs
    Expected input [testChecklistInput] is missing

How can I link the result of the stats list to my attribute checklist?

Thanks in advance!

1 answer

1
0
-1

Hi,

I recommend using the following flow to help you:

  • Create a Business object in the BDM representing your Stat item like: A Statistic object with the following attributes:

    • mean DOUBLE
    • min DOUBLE
    • max DOUBLE A Statistic object with a stats relation (in composition) of type Statistic and mutliple.
  • In a process create a statistic business variable, go to the contract and create the contract from the business varible (Add from data...)

  • Then create a form the process or task with this contract, it should autogenerate a form to create your object. If you are on a task you can use th edit mode when creating the contract to generate a form designed for edition.

Here is a bos file with the above example.

HTH
Romain

Comments

Submitted by marinalles on Wed, 03/03/2021 - 16:16

Hi Romain,

Thank you for trying to help me! I already have a service with predefined statistics and I would like to pass this list in the UI. The idea is to show in the UI some stats as default vales and then give the option to the user to delete some of the default vales and also add other customized stats. The output I want is to have an array with the list of stats that the user wants, like: ["p75","mean","max","custom"], stored in an attribute in the BDM. So the attribute is my case it's a multiple string. I hope this explanation makes it a bit more clear what I am trying to do.

Please find attached the bos file with what I did.

Submitted by romain.bioteau on Wed, 03/03/2021 - 20:35

It is just that in your case, you must adapt the formOutput variable as this expression is bound to $data.testChecklist which is not initialized in your case.
Replacing $data.testChecklist with $data.stats_listin the formOutput fixes this issue.

if( $data.stats_list ) {
        return {
                //map checkList variable to expected task contract input
                checkListInput: {
                        list_stats: $data.stats_list
                }
        }
}

HTH
Romain

Notifications