ecx:forceNumber
    • 1 Minute to read
    • Dark
      Light

    ecx:forceNumber

    • Dark
      Light

    Article summary

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

    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?