how to add validation in UI based on integration response

= a!localVariables(
  local!emails: ri!test.emailAddresses,
  local!individualMail: if(
    a!isNullOrEmpty(local!emails),
    {},
    reject(fn!isnull(_), split(local!emails, char(10)))
  ),
  local!invalidEmails: substitute(
    tostring(
      reject(
        fn!isnull(_),
        a!forEach(
          items: local!individualMail,
          expression: if(
            regexmatch(
              pattern:"^[A-Z0-9\_-]+(\.{0,1}[A-Z0-9\+_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
              searchString: fv!item,
              regexFlags: "si"
            ),
            null,
            fv!index
          )
        )
      )
    ),
    ";",
    ","
  ),
  local!validation: if(
    isnull(local!invalidEmails),
    {},
    "Emails must be in a valid format, and each email must be on a new line. "
  ),

 
  a!formLayout(
    label: "Test",
    contents: {
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!boxLayout(
                    label: "",
                    labelSize: "EXTRA_SMALL",
                    contents: {
                      a!paragraphField(
                        label: "Email Addresses",
                        labelPosition: "JUSTIFIED",
                        placeholder: "Email Addresses should be one per line (can be pasted from Excel)

",
                        value: ri!test.emailAddresses,
                        saveInto: ri!test.emailAddresses,
                        refreshAfter: "UNFOCUS",
                        height: "TALL",
                        required: true,
                        validations: local!validation
                      )
                    },
                    style: "#134f5c",
                    marginBelow: "STANDARD"
                  )
                }
              )
            }
          )
        }
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          saveInto: {

          },
          submit: true,
          style: "PRIMARY"
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancel",
          value: true,
          saveInto: ri!cancel,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )
  )
)





In this interface ,i have already added one validation for email format ,upon click on submit it calls the api, . If the response is not 200&500  i need one more validation based on integration response 

it should throw error on UI saying "emails doesn't exists" on the interface  and user should be able to correct incorrect emails and then resubmit same form again.

can some please help with process model design and interface






  Discussion posts and replies are publicly visible

Parents Reply Children