233
Views
19
Comments
Solved
Clear decimal field having decimal like this 0.000
Application Type
Reactive
Service Studio Version
11.53.21 (Build 61476)

I need to Clear decimal fields having inputs like 0.00, --, -00 while clicking on clear all button. Ideally clear all should show the blank fields but I'm not able to clear these values . All these values are considered as '0' only.


This field is bind with a decimal variable. 

I've tried regex replace but not able to clear this.

Any suggestions how to do this? If I convert it to text var then I'm able to clear all fields but I'm looking to solve this issue with Decimal variable only.




2020-04-21 08-15-30
William Antunes
 
MVP
Solution

Hi Saransh,


OutSystems doesn't handle nulls, instead it has always a default value based on the type. We do however have few options to make it work.

To know what I am talking about, see the default values in https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types

The best option for you would be to keep the input's variable as text, because this is the only way an input can be blank/empty after it has been filled in. 

As your input is a text, you can always either use html attributes to make it look like a decimal or use a mask component that can also do it for you. Basically, your front-end acts like it was a decimal, but ultimately you got a decimal coming down to the database or to the end of your process.


I hope that makes sense.

UserImage.jpg
Saransh

yes, William, I can go with the Text variable but that's my 2nd approach because in our application there are so many places that we're using those decimal values and don't want to change the whole logic that's why looking to solve this issue with Decimal variable only. 

2020-04-21 08-15-30
William Antunes
 
MVP


 Hi @Saransh, I know what you mean. But you can always create your own custom component that can be just dragged and consumed in those places.

Ultimately you will have to change it just a little anyway either to work as a text or as a decimal, as the platform doesn't support it out of the box.

2024-09-17 18-14-33
Miguel Defavari da Silva

Hello!

What are you doing in the ClearAll action?

Maybe you can try the following assign:

This will set the variable to null and your input will be empty.

Please let me know if this worked!

Best regards :)

Miguel

UserImage.jpg
Saransh

no this is not changing anything you can try from your end also I've tried this.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Assigning NullIdentifier() to anything other than an identifier is an anti-pattern. Don't do that!

2024-09-17 18-14-33
Miguel Defavari da Silva

It looks like that Outsystems undestand the "0.00" value as null so this is why it won't be changed.

But if the input is hidden and shown again it will be empty, so this is what I did:

Created a boolean variable and used it on an if condition to hide the input

Created two actions to clean the variable

The first one will set the boolean variable to true and call a Javascript node

This JS code will wait for a number of milliseconds and call the second action

The second action will set the decimal var to 0 e switch the boolean var to false again


This should work!

UserImage.jpg
Saransh

let me try this one.

UserImage.jpg
Saransh

It's not working man. Please first try from your end then give suggestions here.

2024-09-17 18-14-33
Miguel Defavari da Silva

Hello again,

I just tried and it is working.

Can you send your .oml file?

So I can change it correctly and send it back to you.

2024-09-17 18-14-33
Miguel Defavari da Silva

Here it is. Notice that this will clean the variable as well, not only the input. So if you reset the input with a variable = 123, the variable will be 0 at the end.

ClearDecimalFields.oml
2024-09-17 18-14-33
Miguel Defavari da Silva

Got it! Maybe you can implement a loading or something with a better UX.

Just be careful because that solution clears only the input, the variable is still the same, but this should be easy to fix.

Glad to help :)

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

I have Implemented a code to clear the input irrespective of what type of it you can clear them as a blank

I am attaching a Oml file for you to take reference from it

Sample

I hope this will help, Please let me know if you face any issue

Best Regards

Tousif Khan

DemoApplication_Sample.oml
2024-09-17 18-14-33
Miguel Defavari da Silva

Hello!

I was checking your solution to see how it works, will this JS code clean the variable value as well or only the input widget?

Thanks in advance

2023-10-21 19-42-11
Tousif Khan
Champion

This will only for the UI perspective because  Outsystems data type have  default values depending on datatypes,  to make it work then we need to work around, but if we are saving these then the value will depent on its data type

UserImage.jpg
Saransh

Nice it's working as expected.

UserImage.jpg
Saransh

Tousif I'm having 10-12 decimal fields. There I'm running this script and if I type something again in those fields values are coming again. I think it's not suitable for more than one fields.  


Need to go with Text field only.

2023-10-21 19-42-11
Tousif Khan
Champion

Hi,

It will work for multiple field as well, I tried it myself and it’s working. 

I show you the way, we can customise this further accordingly.

2020-04-21 08-15-30
William Antunes
 
MVP
Solution

Hi Saransh,


OutSystems doesn't handle nulls, instead it has always a default value based on the type. We do however have few options to make it work.

To know what I am talking about, see the default values in https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types

The best option for you would be to keep the input's variable as text, because this is the only way an input can be blank/empty after it has been filled in. 

As your input is a text, you can always either use html attributes to make it look like a decimal or use a mask component that can also do it for you. Basically, your front-end acts like it was a decimal, but ultimately you got a decimal coming down to the database or to the end of your process.


I hope that makes sense.

UserImage.jpg
Saransh

yes, William, I can go with the Text variable but that's my 2nd approach because in our application there are so many places that we're using those decimal values and don't want to change the whole logic that's why looking to solve this issue with Decimal variable only. 

2020-04-21 08-15-30
William Antunes
 
MVP


 Hi @Saransh, I know what you mean. But you can always create your own custom component that can be just dragged and consumed in those places.

Ultimately you will have to change it just a little anyway either to work as a text or as a decimal, as the platform doesn't support it out of the box.

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