Validation not being enforced

Hello,

I have submit disabled, validate set to true, required set to true but the required message only appears on one field when clicking save button.

Here is my code for the amount to refund field:

 

                a!sideBySideItem(
                  item: a!textField(
                    label: "Amount to Refund",
                    labelPosition: "ADJACENT",
                    value: if(
                      local!updatedStatus = "Closed - Full Refund",
                      a!currency(
                        "USD",
                        local!data.paymentAmount
                      ),
                      a!currency("USD", local!refundAmount)
                    ),
                    saveInto: local!refundAmount,
                    refreshAfter: "UNFOCUS",
                    required: if(
                      local!updatedStatus = "Closed - Partial Refund",
                      true,
                      false
                    ),
                    requiredMessage: "Amount to refund is required.",
                    disabled: if(
                      or(
                        local!updatedStatus <> "Closed - Partial Refund",
                        local!readonly = true
                      ),
                      true,
                      false
                    ),
                    validations: if(
                      or(
                        a!isNullOrEmpty(local!refundAmount),
                        and(
                          todecimal(local!refundAmount) > 0,
                          todecimal(local!refundAmount) <= todecimal(
                            local!data.paymentAmount
                          ) - 0.01
                        )
                      ),
                      null,
                      "Amount must be less than the original amount."
                    ),
                  )
                )

Here is my code for the tracking field:

                a!sideBySideItem(
                  item: a!textField(
                    label: "Return Tracking",
                    labelPosition: "ADJACENT",
                    value: local!requestDetails.returnTrackingCode,
                    saveInto: local!requestDetails.returnTrackingCode,
                    refreshAfter: "UNFOCUS",
                    characterLimit: 35,
                    required: if(
                      or(
                        local!updatedStatus = "Closed - Partial Refund",
                        local!updatedStatus = "Closed - Full Refund"
                      ),
                      true,
                      false
                    ),
                    disabled: if(
                      and(
                        local!readonly = false,
                        or(
                          local!updatedStatus = "Closed - Full Refund",
                          local!updatedStatus = "Closed - Partial Refund"
                        )
                      ),
                      false,
                      true
                    ),
                    validations: if(
                      len(
                        local!requestDetails.returnTrackingCode
                      ) >= 15,
                      null,
                      "Return Tracking must be at least 15 characters long."
                    ),
                    accessibilityText: "Return tracking input field"
                  )
                )

Here is my code for my save button: 

Please advise..

Thank you.

  Discussion posts and replies are publicly visible

Parents
  • Hi, according to the documentation, when you don't pass any value to the a!currency() function, it returns the ISO code. So, when you click on the button, you will not get a "required value" message in the "Amount to be refunded" text field because the value will be "$". To fix this, I made some adjustments to your code. Refer the code below.

    a!sideBySideItem(
              item: a!textField(
                label: "Amount to Refund",
                labelPosition: "ADJACENT",
                value: if(
                  local!updatedStatus = "Closed - Full Refund",
                  a!currency("USD", local!data.paymentAmount),
                  if(
                    a!isNullOrEmpty(local!refundAmount),
                    local!refundAmount,
                    a!currency("USD", local!refundAmount)
                  )
                ),
                saveInto: local!refundAmount,
                refreshAfter: "UNFOCUS",
                required: if(
                  local!updatedStatus = "Closed - Partial Refund",
                  true,
                  false
                ),
                requiredMessage: "Amount to refund is required.",
                disabled: if(
                  or(
                    local!updatedStatus <> "Closed - Partial Refund",
                    local!readonly = true
                  ),
                  true,
                  false
                ),
                validations: if(
                  or(
                    a!isNullOrEmpty(local!refundAmount),
                    and(
                      todecimal(local!refundAmount) > 0,
                      todecimal(local!refundAmount) <= todecimal(local!data.paymentAmount) - 0.01
                    )
                  ),
                  null,
                  "Amount must be less than the original amount."
                )
              )
            )

Reply
  • Hi, according to the documentation, when you don't pass any value to the a!currency() function, it returns the ISO code. So, when you click on the button, you will not get a "required value" message in the "Amount to be refunded" text field because the value will be "$". To fix this, I made some adjustments to your code. Refer the code below.

    a!sideBySideItem(
              item: a!textField(
                label: "Amount to Refund",
                labelPosition: "ADJACENT",
                value: if(
                  local!updatedStatus = "Closed - Full Refund",
                  a!currency("USD", local!data.paymentAmount),
                  if(
                    a!isNullOrEmpty(local!refundAmount),
                    local!refundAmount,
                    a!currency("USD", local!refundAmount)
                  )
                ),
                saveInto: local!refundAmount,
                refreshAfter: "UNFOCUS",
                required: if(
                  local!updatedStatus = "Closed - Partial Refund",
                  true,
                  false
                ),
                requiredMessage: "Amount to refund is required.",
                disabled: if(
                  or(
                    local!updatedStatus <> "Closed - Partial Refund",
                    local!readonly = true
                  ),
                  true,
                  false
                ),
                validations: if(
                  or(
                    a!isNullOrEmpty(local!refundAmount),
                    and(
                      todecimal(local!refundAmount) > 0,
                      todecimal(local!refundAmount) <= todecimal(local!data.paymentAmount) - 0.01
                    )
                  ),
                  null,
                  "Amount must be less than the original amount."
                )
              )
            )

Children