ecx:forceNumber
- 1 Minute to read
- Print
- DarkLight
ecx:forceNumber
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
The function ecx:forceNumber parses numbers in a string attribute as an actual number. This function works in tandem with exc:formatNumber.
Function Logic
If string_or_number is null:
> return 0else if string_or_number is numeric:
> return string_or_numberelse if string_or_number is convertible to numeric after replacing any , to . to ensure compatibility with different decimal separators:
> return numeric converted value with . as decimal separatorelse if:
> return 1end if
Examples
Function | Returns |
---|---|
<%${ecx:forceNumber(' ')}%> | 0 |
<%${ecx:forceNumber('124.66')}%> | 124.66 |
<%${ecx:forceNumber('124,66')}%> | 124.66 |
<%${ecx:forceNumber('text')}%> | 1 |
Structure
ecx:formatNumber(ecx:forceNumber("user.AttributeType.StringAttribute"))
Was this article helpful?