Data Binding in Form Inputs
Use Check Boxes for Boolean Data
This lesson is part of the Developer Online Class for OutSystems 9 course.

in this lesson we will see how to use checkboxes
to allow users to specify the value of
a boolean attribute the first thing we will do is to change our product definition
we will add a new attribute which will
indicate if a product is imported
or not and you'll notice that due to the name that we gave to the attribute
the platform infers that the data type of the IsImportant attribute
should be a boolean value a boolean data type can only store two
values it's either true or false before we continue
let me just make sure that this attribute is created in the database
and I'll publish for that okay
can close this now and let's go into the ProductDetail so
that we can edit this new attribute here for product
here in the ProductDetail and
what I will do is to create the space for
a new attribute so there
I'll add a new label and here the text is
Is Imported and I will
add a checkbox input this one here
checkbox can only start to values as we said before it's
either checked are not checked so this means that
the variable that need to bind these checkbox to
needs to be of boolean data type
and we will bind
this variable again do the form record and we will choose here
the new attribute we created the
IsImported okay so we can now
edit this attribute let's go back here into the products
and I also want to show here
the new attribute here in the table records so let me drag-and-drop
the attribute and you'll notice that
the platform renders the attribute here in the table records as a
a check image an what I want to do next is to
create a new filter here to hide
the products that are imported and to do this again we will use the check box
input so let me add here the check box input
and we will need to bind this
checkbox to a variable again since we're not using this
input inside form we will need to create a local variable
and we will call it HideImported
and again the platform inferred
from the name of the variable that this is of boolean data type which is correct
we can now bind it to the checkbox and can do this again by dragging and
the variable on top of the
checkbox widget and let's add here
a label Hide Imported
Products and now
we will need to use this variable in the
aggregate we have in the preparation so again go back
here to the preparation open the aggregate and let's
add a new filter let me just show here first
the attribute on the aggregate there
and at this time all the
the products that we have are set with the
IsImported to false because this is a new attribute we haven't set
any of these products as imported we will do that once we publish the application
but now let's create the filter here and the filter will test
when the user ticks the check box in the filter
so when this HideImported
is ticked we only want to show the
non imported products
and the same is to say that when this is not
ticked when the value of the
variable is false then we will show
all all the products here and the condition that we want to write here
is either we want to show all the products
meaning that the value of the variable is false or
we want to show only the ones that are
not imported meaning that the product IsImported
is equal to false
okay so that's our condition we're all set
let's publish and test our application
okay so first of all let's set
a couple of these products as imported let's say for instance that this
Mac Book air is imported
let's save and there you have it the information is stored in the database
let's say that this Dell screen is also
imported there
and let's test our filter let's
hide the imported products and there you have it
the products that were imported are hidden from the list
and that's it