Skip to main content
January 9, 2024
Question

how to add validation in UI based on integration response

  • January 9, 2024
  • 13 replies
  • 0 views

= 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






    13 replies

    stefanhelzle0001
    January 9, 2024

    Your description and process model seems plausible. Maybe add some chaining to route the user back to the interface in case of an issue. Where exactly are you stuck?

    sabat0002Author
    January 9, 2024

    how to add validation in UI based on response received ,if the response says some incorrect emails are present then validation must be  "incorrect emails are present" on the same Ui with all  same fields which was already there

    stefanhelzle0001
    January 9, 2024

    Add a rule input to the interface and display that error message based on a value that you pass in, e.g. the "success" value of the integration call stored to a process variable.