How is your experience with the OutSystems Community?
33
Views
13
Comments
Solved
values do not allow corrections to positive

The problem is that I have a field with a condition requiring only positive values. When a user enters a negative value, they are warned to enter a positive one; the user then deletes the negative sign and proceeds to the next step, but the negative sign reappears on the value even after deletion.

UserImage.jpg
Lina AlsammOue
Solution


The solution we’ve implemented for now is removing the negative sign feature from the mask—as you suggested—since it appears to be a common issue within OutSystems itself

Thank you for your reply and the options provided 


2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hi @Lina AlsammOue,

A question here: does this happen only when he clicks the Submit button, or does it also happen while he is simply typing the number?

My theory is that this behavior is related to the Submit action. The variables used by the screen are probably not being invalidated or reset when the button is clicked, so they remain intact even if you later delete the value. In other words, the value is persisting in a variable or something.

I don't think the issue is in the OnChange event, because if it were, you would not see the same behavior while typing.

If possible, could you share the OML?.

UserImage.jpg
Lina AlsammOue

Hi Sherif,

Thank you for your reply!

To answer your question: yes, this behavior happens only when clicking the Next (Submit) button. While typing or after deleting the minus sign and moving focus away from the input, the value stays correct and positive. The minus sign only returns the moment the Next button is pressed.

Regarding the setup, the input field is indeed bound to an Input Mask component (InputNumberMask). The Input Type is set to Text, but the variable bound to it is a Decimal attribute from an aggregate.

Unfortunately, I cannot share the OML file, but I would highly appreciate your insights based on this behavior.

Thanks again!

2026-06-20 17-43-43
Sherif El-Habibi
Champion

I can think of two possible approaches here.

First option: Why not move this validation to the OnChange event of the input field? This saves you from having to rewrite the logic to clear or reassign the validation variable on the Submit action. It also keeps the validation synchronized with the latest user input. For example, if the user types -5, the validation message appears immediately below the input. As soon as they change it to 5, the validation message disappears.

Second option: As far as I know, an input mask should prevent the user from entering invalid characters, including a negative sign if only positive values are allowed. If it still allows negative values, then either the mask is not behaving as expected or it has been implemented incorrectly.

If, in the end, you still prefer to validate only when the Submit button is clicked, you could skip the mask approach altogether. Instead, use the Regex_Search action from the Text dependencies. On the Submit action, check whether the input matches a regular expression that allows only positive decimal values.

For example:

^[+]?\d*(?:\.\d*)?$

This pattern matches positive integers and positive decimal numbers (with an optional + sign) while rejecting negative values.

I also attached an OML for your reference.

Test__.oml
UserImage.jpg
Lina AlsammOue


Hi Sherif,

Thank you for your reply and the options provided.

Unfortunately, due to project constraints, I cannot change or replace the Input Mask with another approach (like Regex).  

Here is exactly what happens:

When the user enters a negative value, the warning message appears as expected.

If the user then removes the negative sign (or even completely clears the field and types a brand new number) and clicks the "Next" button, the field instantly reverts back to the old value containing the negative sign.

2026-06-20 17-43-43
Sherif El-Habibi
Champion

I think the core issue is a mismatch between the submission logic and the bound variable. When you type or delete the minus sign, the change updates the display, but it may not be syncing back into the actual Decimal variable. So when you click Submit/Next, the logic operates on the old stored value (still negative) rather than the newly typed one which is why the minus reappears.

So the thing to check is: is the variable actually being updated the moment you edit the input?

I'd also recommend launching the debugger and placing a breakpoint on the submission logic that'll let you see exactly what value the variable holds at Submit, and confirm why it's retrieving the negative one.

UserImage.jpg
Lina AlsammOue
Solution


The solution we’ve implemented for now is removing the negative sign feature from the mask—as you suggested—since it appears to be a common issue within OutSystems itself

Thank you for your reply and the options provided 


2026-06-20 17-43-43
Sherif El-Habibi
Champion

Glad it worked out, happy to help anytime.

2026-03-27 07-32-35
James Padua

Hi,

Based on what you mentioned, I'm assuming the UI part of your issue is already resolved. The input field is not showing the negative sign but in the backend, it is still saving as a negative value. The easiest way to fix it is by using Abs(variable) function just before saving the record. You can add Abs() dependency from Math module.

UserImage.jpg
Lina AlsammOue

Hi James,

Thank you for the suggestion to use the Abs() function.

The main challenge here is that the Input Mask component seems to be caching the negative value internally. Even if the user manually removes the negative sign or completely clears the field to correct it, clicking the "Next" button forces the Input Mask to overwrite the variable with the old negative value.

While Abs() could convert a negative number to positive in the logic, it doesn't solve the core issue of the component overriding the user's manual input and rolling back to old data when they try to proceed. I need the input field to properly accept the user's manual corrections without this forced rollback.

Have you experienced this kind of caching or reverting behavior with the Input Mask before?

2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello @Lina AlsammOue 

You can use js to archive this easily just add this js functtion with your input id 

function allowOnlyPositive(inputId) {
    const input = document.getElementById(inputId);

    input.addEventListener("input", function () {
        this.value = this.value.replace("-", "");

        if (this.value < 0) {
            this.value = Math.abs(this.value);
        }
    });
} 


call function:-  allowOnlyPositive("Input1"); 

If the user types -123, it will automatically become 123, and the minus sign won't reappear. This provides a smoother experience than showing a validation message after the value is entered. 


Thanks

Gourav Shrivastava

UserImage.jpg
Lina AlsammOue

hello Gourav 

Thank you for the suggestion. 

However, the requirement is for the user to be able to enter a negative value, receive a warning to enter a positive value instead, and have the negative sign removed. The problem I am facing is that the system re-enters the initial negative value even after the modification.

2026-03-20 01-28-51
Saugat Biswas

Hi @Lina AlsammOue ,

This is the expected behaviour for UI/variables. The UI / variables holds the values unless it is changed by client action. The best course will be to validate the form and if the value is negative, show message and invalidate the form.  This will ensure that your client action does not call the server action to update the data.

Else you may need to use ABS() function to convert it to positive number and your error message should indicate that negative number is converted to positive.

Hope this helps,

Best,

Saugat

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

Hi Lina,

Have you tried to make a simple module that displays this behaviour, one that you could post here? That would be very helpful for troubleshooting.

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