Field Service

Get Involved. Join the Conversation.

Topic

    Ben Abbott
    Forcing 2 Decimal Places on a String Property in Mobility
    Topic posted March 21, 2019 by Ben Abbott, tagged Configuration, Mobility / Mobile Apps 
    67 Views, 4 Comments
    Title:
    Forcing 2 Decimal Places on a String Property in Mobility
    Summary:
    A field called "subtotal_markup_parts" has a regex configured, but the values are not constrained once the field is calculated
    Content:

    Hello,

    The customer has a string property called "Subtotal w/ Markup" [label = subtotal_markup_parts] which has a regex configured:
    /^(?!.{8,})\d{1,6}(\.\d{1,2})?$/

    The regex is supposed to force the value of this property to be limited to 2 decimal places, however it seems that since this property displays the calculation of two other properties, the regex doesn't work. See the below 3 screenshots:
     


    subtotal_markup_parts is configured as so =  subtotal_markup_parts.png
    name: Subtotal w/ Markup
    label: subtotal_markup_parts
    regex: /^(?!.{8,})\d{1,6}(\.\d{1,2})?$/

    It is configured in the display to show the value of the product of these two fields =   subtotal_end_activity_screen.png
    Default Value: (activity.subtotal_parts * activity.markup_parts)

    And then in the instance, we can see that the regex doesn't apply and that the property incorrectly shows 6 decimal places =  subtotal_mobility.png
    >> the value displays as 168.936375  when it should be 168.94

    Why doesn't the regex apply to a property that displays calculations? 
    Also I know that this property could use language expressions but there doesn't seem to be a way to for the limit of 2 decimal plays for a number - are there any other ways this might be accomplished?

    Version:
    19A (19.2.4)
    Document:

    Comment

     

    • Marc ***

      We are also trying to accomplish what you describe (round a $ amount to 2 digits after the decimal).

      I think the RegEx is only used for validation and doesn't enforce how the field will display? What we need are "RoundUP / RoundDOWN" functions with the ability to specify how many characters after the decimal to ROUND.

      FYI we also have examples (currently with Oracle for investigation) where we are adding (+) 2 basic $ amounts (both amounts only have 2 digits after the decimal) however the SUM is displayed with 14 digits after the decimal...

    • Zsolt Tolgyesi

      Hi guys,

      Maybe I'm wrong, but not
       toNumber(value) Formatting object to required number format
      is the function what you're looking for?

      https://docs.oracle.com/en/cloud/saas/field-service/19a/faadu/configure-oracle-field-service-cloud.html#r_typeConversion
      I mean, let the system calculate as many digit as it wants, but show the result formatted to 2 decimals.

      Regards,
      Zsolt

      • Marc ***

        Hi Zsolt,

        I did try toNumber before and it didn't work. Maybe I'm not using it properly?

        I replaced "value" with my existing default value formula (activity.a_labor_charges_total + activity.a_special_charges_total + activity.a_mhf_charges_total) but it still displays for ex 114.96000000000001 when I am only adding 14.95 + 100.01.