How to create a boolean to integer in a mobile app for use in an expression
Application Type
Mobile

I am trying to create a mathematical expression using range slider values and checkboxes. I know that the checkboxes are in boolean and cannot be used in an expression until converted to an integer, so I am trying to figure out how to get a checkbox to return an integer value (1 or 0) so that it will allow the variable to be used in an expression. I am extremely new to outsystems and am using it for a senior design project.

mvp_badge
MVP

Hi Madi,


You can have a variable of type integer and use an assign to set it to 1 if boolean is true, and false otherwise, like in the image below:


Kind Regards,
João

When I try to do this, it tells me that my data type needs to be in boolean which the variable I am using is.

mvp_badge
MVP

Can you show a screenshot of the BooleanVar properties, including the data type?

Hi Madi, 

In addition to João answer, there is a Built-in Function you can use in expressions under the Data Conversion category. You can use it straightforward to achieve what you want to do without using auxiliary variables.

Best regards, 

Víctor

I have been trying to use this function but I get an error every time I try to use it. Is there a specific place I need to be using it? The error I get will say the rest of my expression will not work, or that the data type is not boolean when it is.

If you share some screenshots it would be easier to help you

Screenshots

Where are you tring to use the function with your boolen? Can you open the expression editor? It's what I'm showing in my screenshot.

Hi.

Can you be more specific with the use case?

And It's important you share the error that appears.

Regards

Gonçalo Almeida

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.