How is your experience with the OutSystems Community?
17
Views
5
Comments
Number data type
Question

Hi All,

I have postal code which accepts hiphen with number,When I set the attribute as Number and in api the field is text still before sending to api it was converting to 0 .

When I have set the attribute on screen as Text ,then the value is passing correctly to api.

Can suggest the reason.

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Preeti zade ,

If the postal code contains a hyphen, the conversion from Text to Number(Integer/LongInteger/Decimal) can fail and default to 0 before reaching the API.

You can use the TextToIntegerValidate/TextToLongIntegerValidate/TextToDecimalValidate functions to check if your valid is a valid number.

I would say in your case keeping the variable / attribute and API mapping as Text is the correct approach. 


UserImage.jpg
Preeti zade

Thank you Mihai,

Yes I will sync with api data type but in screen it will enter text so we need to chk to mask chars

2026-01-28 16-57-48
Mihai Melencu
Champion

Do you have an input widget on the screen, and is the API called based on the value entered there?

If yes, do you need to follow a specific postal code format? In that case, you should keep the field as Text and add validation, and optionally an input mask, to control the allowed format.

2025-08-07 06-30-56
Amit J
Champion

Hi Preeti zade ,

Because the Postal Code field contains a hyphen (-), it is not a valid numeric value. When the screen attribute is defined as Number, OutSystems tries to convert the entered value to a number. If the value contains non-numeric characters such as a hyphen, the conversion fails and the value may become 0 (or Null depending on the data type and logic) before being sent to the API.

When you change the screen attribute to Text, OutSystems preserves the value exactly as entered, including the hyphen, so the API receives the correct value.

Postal codes should generally be stored and handled as Text rather than Number because many countries have postal codes that contain hyphens, spaces, leading zeros, or even letters (for example, '12345-6789' or 'SW1A 1AA'). Using Text avoids conversion issues and ensures the original format is maintained."

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