a!currency: force recognize "," instead of "." as decimal

My application is specifically for a local where the decimal symbol used is comma " , " and not a period " . ".
So, the decimals will be inputted by the portal users as `5,55` instead of `5.55`

So my current code is the following:

a!textField(
  label: "The amount of money for payment",
  labelPosition: "ABOVE",
  instructions: "",
  helpTooltip: "The amount of money for payment",
  value: if(
    local!variant_value_for_payment > 0,
    a!currency(
      isoCode: "BRL",
      value: local!variant_value_for_payment,
      format: "LOCALE"
    ),
    null
  ),
  saveInto: {
    a!save(
      local!variant_value_for_payment,
      todecimal(save!value)
    )
  },
  refreshAfter: "KEYPRESS"
),

I've read the a!currency docs and the main question for the best solution for me should be:

→ How may I be able to forcely make the system reads "100.50" and recognizes as " 100.00" and keeps that format?

Thanks from now on

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    For your first question of reading with ","... Use Substitute(), Hope the following code helps

    a!localVariables(
      local!variant_value_for_payment,
      local!valueforpayment: a!refreshVariable(
        value: if(
          a!isNullOrEmpty(local!variant_value_for_payment),
          null,
          todecimal(
            fn!substitute(
              local!variant_value_for_payment,
              ",",
              "."
            )
          )
        ),
        refreshOnVarChange: local!variant_value_for_payment
      ),
      a!textField(
        label: "The amount of money for payment",
        labelPosition: "ABOVE",
        instructions: "",
        helpTooltip: "The amount of money for payment",
        value: if(
          local!variant_value_for_payment > 0,
          a!currency(
            isoCode: "BRL",
            value: local!valueforpayment,
            format: "LOCALE"
          ),
          null
        ),
        saveInto: {
          a!save(
            local!variant_value_for_payment,
            save!value
          )
        },
        refreshAfter: "KEYPRESS"
      ),
      
    )

    How may I be able to forcely make the system reads "100.50" and recognizes as " 100.00" and keeps that format

    For this Abhishek's code might help

Reply
  • 0
    Certified Senior Developer

    For your first question of reading with ","... Use Substitute(), Hope the following code helps

    a!localVariables(
      local!variant_value_for_payment,
      local!valueforpayment: a!refreshVariable(
        value: if(
          a!isNullOrEmpty(local!variant_value_for_payment),
          null,
          todecimal(
            fn!substitute(
              local!variant_value_for_payment,
              ",",
              "."
            )
          )
        ),
        refreshOnVarChange: local!variant_value_for_payment
      ),
      a!textField(
        label: "The amount of money for payment",
        labelPosition: "ABOVE",
        instructions: "",
        helpTooltip: "The amount of money for payment",
        value: if(
          local!variant_value_for_payment > 0,
          a!currency(
            isoCode: "BRL",
            value: local!valueforpayment,
            format: "LOCALE"
          ),
          null
        ),
        saveInto: {
          a!save(
            local!variant_value_for_payment,
            save!value
          )
        },
        refreshAfter: "KEYPRESS"
      ),
      
    )

    How may I be able to forcely make the system reads "100.50" and recognizes as " 100.00" and keeps that format

    For this Abhishek's code might help

Children