Hi,

I would like to validate input field which is defined as Integer in database. When creating a record this field is filled with default value 0.

When I open my mobile screen containing the form and the input field inside, there is no value seen in the input field (for some reason 0 value taken from database is treated as empty value). 

I want to validate if there is any input in the input field but there is no such a function when working with mobile app as opposed to web app where we have "Typed value" runtime property.

How to solve this? How to check if user input any value into the input field in mobile app?

Solution

Hi Michal,

You could use a JavaScript control with as Input parameter the Id of the input box (e.g. InputId), and as output the Value (e.g. Value). Use "$parameters.Value = document.getElementById($parameters.InputId).value" to obtain the value. It's not ideal, but it works.

Solution

Hi Michal,

In the new version of the Platform Server (10.0.603.0) we've introduced a new attribute that will allow you to show the default value in inputs.

Here's the release note:
* Added a Boolean attribute ("show-default-value") to the mobile Input widget. When true, the default value of each type is rendered instead of showing an empty input. (RAFT-579)

best regards,
Hélio


Hi Helio,

Thanks for your response.

The case is that the input does not show the value even when in database is 0 value. So it's not that there is nothing in the database. If I input 0 and save and open it again it shows nothing.

Hi again Michal,

Michal Witek wrote:

So it's not that there is nothing in the database. If I input 0 and save and open it again it shows nothing.

This is the default behavior of the inputs in the Mobile. Zeros are always cleared if the value is empty or zero. 


The integer values are never Null, even if the record is empty. The value will always be zero.
With the new property I've mentioned above you'll be able to show the value 0 instead of an empty input. 

If you want to check if the database value is null, you'll have to check the Id field of that Entity Record.


Best regards,

Hélio



Hi Hélio,

Why is the typed value of the input control not available on mobile? It's easy enough to retrieve (see my post above), but it would be easier if it were just available like on web apps. Also, why is there no Null Value like on web app inputs?

Hi Kilian, Hi Helio,

I am also surprised that the typed value is not available on mobile. I will report this as improvement in the platform. I did workaround proposed by Kilian with use of Java Script - it works.

"This is the default behavior of the inputs in the Mobile. Zeros are always cleared if the value is empty or zero." - this is also problematic to me. It shouldn't be like that casue input value 0 is also a value and it should be seen by default. I will request for the platform server upgrade hoping it will solve the issue.

Thanks for your assistance.


Hi guys,

The typed value is not available in mobile because it is automatically bind to the variable, that means that the OutSystems variable should always contain the most recently typed value in the onChange (or any other) input event. Unless you need to see the type event data, you shouldn't need to attach manually to the input event using JavaScript.

Regarding "Null values" /"Default values" we have just introduced the "show-default-value" attribute to make it possible to show zeros, default dates/datetime, etc. and that should cover the most common use cases. The "Null Value" wasn't really easy to explain, and 99% of time it was used to show the default value. It wasn't a good decision keep it outside the MVP, but we are listening to your feedback and adding these things as soon as possible.

By the way...we also solved a couple of issues writing decimal values in this Platform Server revision.

Best regards,

Hélio


Hélio,

It may be automatically bound to the variable, but if I type "12312123123123123123" in an integer input box, my variable is 0 but that's not the typed value. And if I type nothing, the input box is empty but the value is 0...

Hi Kilian,

You are correct, typing something invalid/too big will lead to zero and that's the same behavior we have for the Web Runtime, because of the type precision. 

And you are also correct that we had the runtime property with the typedValue that would show the actual visible value in the browser. In the Mobile runtime you'll have to access the "input.value" using JavaScript to get the old TypedValue.

Regarding the "And if I type nothing, the input box is empty but the value is 0..." part, If you use the "show-default-value" attribute you'll see the 0 instead of an empty box.

Is there any use-case not covered by these features? Or is this just a different way of doing things? I'm not saying this is better, but the most important thing now is to see if we are covering everything important an then iterate in the UX.

Thanks!



Hi Hélio,

As for the "show-default-value", I think there are good use cases for diffentiating between "no input" and "default value input". That's not solved by only having that setting (but would be solved if there was a way to check the actual input box value).

Also, though I'm not sure how it relates to the web app input box behaviour, I noticed that unless I set the "Built-in Validations" on the button to True, the Valid property of the input box isn't set. It would be nice to have the Valid set to False if the input was out of bounds (like in my previous example) but without triggering the ugly default screen messages (which mess up the layout pretty bad).


Hi Kilian,

The "show-default-value" is a boolean attribute that can be changed in runtime (using a conditional expression in the value). So you can do that type of logic to show if is changed by the end user. 

Unfortunately the "Built-in Validations" must be activated so that the validations are activated. That's a bit odd but we can't change this right now as it would be a breaking change in the product. We will definitely look into the validations in the future. I'm not sure if we can make those changes but I will forward the feedback you gave to the correct team. 

Thanks!

Hi Helio,

I did the upgrade to Platform Server (10.0.603.0)Unfortunately I don't see the change that you mentioned, namely the new  attribute "show-default-value".

Could you please let me know what may be wrong?


Thanks in advance.

Hi Michal.

The attribute is not visible in Service Studio but you can add it this way:

Let me know if it works.

Hélio

Hi Helio,

Thank you for the information.

How to set it in runtime?


Michal

Michal,

You can use a variable instead of the "True" literal? I assume setting it to "False" works to hide it?

Why do you want to change it in runtime at all?

Hi Kilian,

I need to get back to my first input and the issue that I want to resolve. The mobile input does not provide what has been typed by the user in the input. I want to create a form in which all inputs are empty when first opened by the user in order to make the user to input the required values. Due to the fact that these input fields are numeric and I am taking them from database, the defaults are 0. When the app takes data from database it takes 0 and previously without the attribute it was showing empty fields. Now when the attribute is set to True the values are shown as 0. And this is also not the right behavior for first open of the form as it looks like the user input 0 to the form whereas it haven't input anything.

Please note that 0 is also the correct range in the form fields.

Hi Michal,

As Kilian said, you can use an expression instead of simply setting to "True". You can assign it to a Boolean variable value that maps your "show" condition.

Hélio

Hi Kelio,

I have followed your instruction with variable that controls the state. It didn't work. So I put two buttons on the form "Show default" and "Don't show the default" with corresponding actions changing the variable value to True or False. When I click on the buttons nothing changes whereas the fields should change acordingly to the variable value. 

Based on this I assume that there is some error or I am doing something wrong. Please advise.

Hi again Michal,

I'm sorry, you're right, we probably didn't consider this dynamic use case, and I was assuming by having an expression it could be changed in runtime. I will try to allow it in a next release. 

There's an easy (but not pretty) workaround which consists on having 2 inputs (just one with this property) bound to the same variable with an external IF condition.

Hélio

Hi Helio,

Yes, I duplicated the inputs and put them into IF. It's not pretty but given that I have spent on the whole issue several hours, I am happy to see it works :)

Thanks for your and Kilian's assistance.