394
Views
9
Comments
Entering zero in number field not showing up

I have a form with an input field for number. When I enter any other number besides zero, it shows up when I bring up the form for editing; but when I enter zero, it shows up as a blank field. As this field is supposed to be mandatory, user has to keep putting zero in there before they are able to save every time which is bit of a nuisance.

Is there any way to get a ZERO entered into the form to be saved and shown in an edit form?

I have seen multiple posts about this but it is not clear on how to get it done. Appreciate any help!

I also have another field which is not mandatory and I need to know whether user filled in zero or left blank.

2023-04-16 15-25-31
Krishnanand Pathak

Hi SP99,

Change the Data Type of attribute to Text then I will show 0 as well.
And restrict the User to enter only numbers using regex.

Regards
Krishnanand Pathak



UserImage.jpg
SP99

Since the column is a number, outsystems shows a warning when I set the input type to text but let's say that's fine. 

How do i restrict user to only enter numbers using regex. Pointer appreciated!

2023-04-16 15-25-31
Krishnanand Pathak

To remove warning the create a variable of Type text.
Then while saving the assign source column with the Text variable by converting the TextToInteger.
While update assign the Text variable at OnAfterFetch from aggregate value.

Try the below component
https://www.outsystems.com/forge/component-overview/14672/restrict-characters

2023-04-16 15-25-31
Krishnanand Pathak

Hi SP99

Sharing the oml in which I perform the same thing as mentioned above.
There are two screens ContactDetailDetail, ContactDetails.

At ContactDetailDetail we are taking input as text(That allow only number) and storing in db as number

You can check the demo to see how it will work through below link.
https://personal-qmzjggmd.outsystemscloud.com/OnlyChar/ContactDetails


Regards
Krishnanand Pathak


OnlyChar.oml
UserImage.jpg
SP99

Really appreciate your help. One more thing. If a person does not enter anything in the Contact field, the field shows 0 when you view it. How can we show it to be nothing if nothing is entered, and zero if zero is entered?

2023-04-16 15-25-31
Krishnanand Pathak

As you mentioned earlier, This field is Mandatory .
Then Just set the Mandatory to True as shown below. So, that user has provide contact at least 0 or anything.

UserImage.jpg
SP99

Hi Krishnanand,

I do have another number field that is not mandatory and I want to that field to show 0 if person enters 0, and blank if nothing is entered in that field.  This form needs to be editable by different people and they need to see the value entered in the field. 

Currently the input field shows up blank if someone enters zero. 

Appreciate your input.

Thank you

2023-04-16 15-25-31
Krishnanand Pathak

To do this you need to change the Db table attribute data type to text.

So, that it can store empty as well.

from UI side restrict the user to enter only number.

2022-12-30 07-28-09
Navneet Garg

did you get the solution if not please check the following thread

https://www.outsystems.com/forums/discussion/33763/outsystems-ui-input-widget-doesnt-display-zero-value/

if yes please mark it solved.


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