Hi, allAbout DB flag, I want to define it as follows,1 -> ON,other -> OFFHowever, I have some concerns because OutSystems does not accept NULL.Should I set a default value for something that is set to 0 in the DB definition?But it requires a lot of work, I guess.
DB-wise, if nothing is set, it will be NULL but OutSystems does not identify NULL value.
What are the best practices?Regards,Sammy
Hi, @Sammy A ,
As I can understand your requirement, you want a boolean variable that will be set to "true"/1 for some conditions and "false"/0 in other conditions.
So if you create an attribute in an entity and define it's datatype as boolean and it is non-mandatory, then it will be by default false if you don't assign it explicitly.
If you want to consider three values: null, False and True, then you can follow the approach mentioned by Daniel Kuhlmann in the reply to the following question:
https://www.outsystems.com/forums/discussion/55071/how-can-i-get-null-booleans-into-an-outgoing-payload/
For exploring more about Default, follow the documentation further from this link.
https://success.outsystems.com/documentation/11/reference/outsystems_language/data/database_reference/default_values_on_database/
I hope this addresses and clears up your question.
Hi @Sammy A,
For this you can use Boolean Fields:
Hope this helps!
Regards,
Deepika
Hi @Deepika PatelI appreciate your kind supoprt.I have a question.What exactly does a boolean field mean.Regards,Sammy
Hello, @Sammy A
This post will helps you. please check
https://www.outsystems.com/forums/discussion/42152/null-is-not-0-os-drawback/#Post154494
Best Regards,
-- Priya Jhode
If the flag is meant to be a simple ON/OFF switch, use the Boolean data type in OutSystems to avoid the complexity of handling NULL values. If you must work with a column that can be NULL, ensure your logic correctly handles NULL values. However, it’s generally better to avoid NULLs for boolean flags by using default values.
for Null values in DB, OutSystems responds as following in the Outsystems environment.
Null text in DB is considered as empty string or ''
Null Number (integer, long integer etc) in DB is considered as 0
Null Boolean in DB considered as false
Null Date or Datetime in DB considered as '1900-01-01'
Boolean values used with fields can have only two possible states like (true/false, active/inactive etc). If your requirement is to have three values (true, false and null) then better to use lookup table and link the lookup table Ids with your main table. in this way you have the appropriate values and the text as well which you want to display to user in case of Null (Others, Not selected, N/A etc)
Hope this Resolve your issue
Hi, allWhat will happen in external DB situation?
Will external DB defaults prioritize?
Sammy
@Sammy A, in external DB situation the Outsystems behavior will remain same as I described earlier.
Hope this will help