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.
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.
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.
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.
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
no this is not changing anything you can try from your end also I've tried this.
Assigning NullIdentifier() to anything other than an identifier is an anti-pattern. Don't do that!
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!
let me try this one.
It's not working man. Please first try from your end then give suggestions here.
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.
can u send your OML please.
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.
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 :)
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
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
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
Nice it's working as expected.
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.
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.