The function ecx:forceNumber parses numbers in a string attribute as an actual number. This function works in tandem with exc:formatNumber.

Structure​

ecx:formatNumber(ecx:forceNumber("user.AttributeType.StringAttribute"))

Function Logic​

If string_or_number is null:

return 0

else if string_or_number is numeric:

return string_or_number

else 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 separator

else if:

return 1

end if


Examples

Code

Returns

<%${ecx:forceNumber(' ')}%>

0

<%${ecx:forceNumber('124.66')}%>

124.66

<%${ecx:forceNumber('124,66')}%>

124.66

<%${ecx:forceNumber('text')}%>

1