Database Updater question:what is the "Condition" column?

Would like to learn what this column is and how it is used. What is its purpose?
Thank you

You can use a condition there to update a certain value if this condition is met. For example - update the specific database table field if an input has a specific value

{{$_POST.someInput == 123}}

I was hoping this was the reason but I spent hours yesterday trying to prevent a value in a form field from going into the database if there was nothing input on the form. In this case, the calendar component apparently alway has a value of ‘’ (empty string) when no date has been input.
In SQL Server’s DateTime column, this results in the value ‘1900-01-01’ being inserted. Since this is a nullable column I want to preserve the default NULL value if the user has not specified a date.

This expression should check for an empty string:
{{’!’+$_POST.EmpDateTo_2==’’’’}}
(this was assembled by the data picker…I don’t know if it is correct because of the escapes)
But it results in the db column never being updated.

it just {{$_POST.EmpDateTo_2}}

So if you want to check if the input sends an empty value and don’t want to update the field in the database you need to use:

{{$_POST.EmpDateTo_2 != ''}}
1 Like

This works, thank you.

This works. Thank you.

As noted above, either of these two expressions work:
{{$_POST.EmpDateTo_2}}
{{$_POST.EmpDateTo_2!=’’}}

Part of the issue here is Wappler insists on escaping strings in the picker dialog, which I am using.
2022-10-20_07h09_30
2022-10-20_07h09_56

I’ve also run across this escaping issue on many of my form’s conrols when adding Dynamic Attributes, etc. I have to go into the code view and remove the escape characters.

Using the picker is nice but it is misleading.

1 Like

Because you need to enter expressions like these in “Code” mode. Entering them in “Design” mode makes them a string.

Does the design mode serve any purpose then?

Yes, for general picking of expressions, which are used in most of the cases.

{{$_POST.EmpDateTo_2}}
This only works if you not send these inputs, e.g. a disable inputs in the form after submiting.

Case 1: If column accepts NULL is not neccesary the check if it’s empty in database updater. Working only with same $_POST variable to check if exists or not, because the validations comes from the form in the UI disabling the input if not user interaction exists, in this case exists other inputs that depends from others and allow to do that, sending a disable input becomes as NULL and in the condition in database updater is only necessary {{$_POST.EmpDateTo_2}}, is not the same sending an empty value '' like not sending the input, but of course, if only exists one input and not chance to disable the input in the form what Teodor explain is the way.

Case 2: Sending an empty input is only neccesary declare the dafault value from the database, in this case like the column accepts NULL you should provide default valur in “Value” column in database updater and not Condition. {{$_POST.EmpDateTo_2.default(NULL)}}.

Thank you.
Not sure if I understand all that wrote correctly, but…
When I simply copied from the “Value” column to the “Condition” column everything worked perfectly and there was no need to make the Condition any more complex. I did this on every database column typed as ‘text’, ‘datetime’ and ‘number’. All columns typed as ‘boolean’ (and they are also nullable in the database) worked fine without using the expression in their columns.

Indeed, when I check the incoming query using the SQL Server Profiler tool you can see that Wappler is doing exactly what I want: sending NULL values istead of empty strings:

Setting up the Conditions this was was quick and easy and now my database records inserted by Wappler will be clean.
Thanks again for all of your help!