Is possible to use a static entity in this scenario?

I have a screen that has a table similar like this:

This table is associated with a process (processId) and this table is static html, all text is static, for example the text "Some text 1" is static, never changes is always "Some text 1" and Im using a text widget to show the text.

The only interaction in the page is that the user should be able to check/uncheck the checkboxes.

My doubt is how to properly store the user interaction (check/uncheck the checkboxes). In the image there are only 8 checkboxes but in this scenario there are 30 checkboxes. Its possible to create a static entity with multiple records like “check1, check2,…check30”? There is the isChecked column for each record so maybe this column can be used to check/uncheck the checkboxes. However, I dont know if is possible to use a static entity for this, the isChecked column is there but this column would be necessary to be updated based on user interaction (check/uncheck checkboes).

 In this case the isChecked column would be updated based on the user interaction. Do you know if its ok to use a static entity for this scenario? Thanks!

Rank: #127

Hi Jake,

You would probably benefit from following some of the training, there are good sections on data modeling,  explaining  what static entities  are for.  They are not for storing user entered data.  

We don´t know enough about your use case to really help.  These 30 checkboxes, are they relating to the user or to this process ? Judging by what you said,  i´ll guess the last.  So you´ll probably want a normal entity with a record in it for each process, with process id as identifier, maybe.  

For a beginner, then maybe start as you suggested with attributes checkbox1 to checkbox30.  To me, both this and the choice to have everything on your screen hardcoded is something you´ll regret later, as the sentence ´ this never changes´  is very often heard and rarely correct in the design phase of software.

Happy coding,


Rank: #7218

Thanks, yes the 30 checkboxes are related to the process. But so the way you are saying is create 30 records in a regular entity? But thats also ok? Because this is really static the only thing dynamic is the check/uncheck of the checkboxes, but the number of checkboxes is static and also the html table, the text is all static.

Rank: #312

Hi, if the Some Text 1,2,3 are always the same text, you can show this on the page by using a table records and an aggregate of the static entity. In the aggregate, define another column with the expression "false". This allows you to bind the checkbox to it, and while saving the page/form you can loop trough the aggregate containing the static entity. 

You can then write logic to save all this in your database. You can also write logic to make the checkbox on the left auto check all the boxes on the right. 

Rank: #7218

Hi, thanks but the logic to store on the database when the user checks/uncheck a checkbox will be stored on the static entity?

Rank: #312

No that is not possible, static entities cannot be changed by the end-user in your application. So you have to create a separate table to store the results of the checked boxes, but the texts can be showed from your static entity.

Rank: #7218

Thanks, but the texts are static html, are already in the web screen using the text widget so why the static entity is necessary? Can you explain better, for example what entities and relationships are you saying with your solution? Thanks!

Rank: #493

Hi jake,

In order to choose the solution, you will need to consider how often the CheckBoxes could change.

You will need 30 variables, one for each CheckBox, so, or you create an Entity with 30 attributes, or you will need to create 30 local attributes.

On the First solution, you will need to create an entity with at least 30 attributes just for the CheckBox. Is easier to save and change. Even if the Entity will hold only one record, the fact that you will not need to change a lot of things to make changes is a really good thing.

On the Second solution, you can create an Entity with at least 3 attributes (UserId, CheckBoxId, isChecked). You can use a Static Entity (Using a Static Entity will prevent problems with broken constraints) for the CheckBoxes (with at least CheckBoxId, CheckBoxName). If you want, you can save only the checked ones on the first Entity.

Best regards,

Rank: #7218

Thanks, can you expalin better the second solution? How the interaction (check/uncheck the checkbox) would work on the database? Im not understanding why the static entity is necessary. And yes there are only 30 checkboxes and in this context is not need to change.

Rank: #493

You will create an entity to manage the values of each check box as a record.
UserId, CheckBoxId, isChecked.
1, 1, true
1, 2, false
1, 3, true ...

For each CheckBox on the screen, you will have a record on the entity above.

On this solution you will have to iterate over the CheckBoxes to save the values on the database and, also, you will have to iterate over them in the preparation (a lot of work)

I would recommend a static entity for better readability and for use it in constraints, but it is up to you. You can think of static entities as enumerations.

How often the values of this screen will change and how many user will have permissions on it? You can save it on a file too, but you will have more work ...

I still think that the first solution is easier to create and maintain.

Rank: #7218

Thanks! Can you explain what is the difference of the first solution?

Rank: #493

In the first solution, you don't need to create 30 local variables or a structure, because you will use the entity created as source of the check boxes. You will use the autocreated methods to update the entity, so there are no more work here. Thus, you won't need to manually handle each check box value in order to save it in or in order to get them from the database. In this solution, all the values is just one record.

UserId, CheckBox1, CheckBox2, CheckBox3 ... CheckBox30
1, true, false, false, ... true

In the second solution, you will have to iterate over the 30 values to create/update one by one, because they are different records of the entity. 

UserId, CheckBoxId, IsChecked
1, 1, true
1, 2, false
1, 3, false
1, 30, true

Rank: #493

I can think in others solutions, but all of them will need extra work to be done, and this will only create unnecessary work. 

Rank: #7218

Thanks, so now I have a static entity "StaticTexts" with records like this:

id   Label Order Is_Active
1 Some text 1 True

And a entity to store the checked checkboxes "StoreCheckboxes"
id ProcessId StaticTextId IsChecked

Now in the screen, I already have the static html table but Im not understanding how to use this db model.

I can have in the preparation an aggregate StaticTexts with or without StoreCheckboxes where StaticTexts.Id = StoreCheckboxes.StaticTextId but then how to associate this with the table?

Rank: #493

You cannot use a static entity to hold the values, because you cannot change them at runtime, just in design time.

  1. Create an entity, let's say: StoreCheckBoxes.
  2. Create 30 boolean attributes in it, one for each Checkbox.
  3. On the screen:
    1. Create a preparation
      1. Drag and drop the entity on the flow to create the GetStoreCheckBoxes aggregate
    2. Drag and drop a form widget on the canvas
      1. set the Source Record as GetStoreCheckBoxes.List.Current
    3. Drag and drop your entity on the form
      1. configure the inputs as you need (labels and positions)
    4. Add the a button save to the form
      1. on the destination property, choose (New Screen Action)
      2. on its flow, drag and drop the CreateOrUpdateStoreCheckBoxes action (created automatically by OutSystems to the Entity)
        1. set its Source property as Form.Record

If only one registry will be on the database, this will work fine.

Rank: #7218

Thanks but Im not understanding the step 3 and forward, why to use a form widget? I have a html table as it is in the image, the user should be able to check/uncheck the checkboxes to update the status of the checkboxs and thats it for that I can use the OnChange event. But my doubt is how to display the texts and the checkboxes on the table.

Rank: #493

It is not mandatory, but will save you a lot of work. Do it in another screen for testing and you will understand it. The OutSystems will create the CheckBoxes and respective labels with the appropriate variable sources.