How to save the error message from a field validation

Is there a way for me to save the error message from a field validation so that I can show it at a later stage on a different form and user task?

OriginalPostID-223308

OriginalPostID-223308

  Discussion posts and replies are publicly visible

Parents
  • You can use the same expression which is used for validation to save the error messages in a rule input. You can refer the following code for more understanding:

    load(
    local!firstName,
    local!lastName,

    a!formLayout(
    label: "Form",
    firstColumnContents: {
    a!textField(
    label: "First Name",
    value: local!firstName,
    /* validations: if(len(local!firstName) > 10, "Number of characters in first name must be less than 10", ""), */
    saveInto: {
    local!firstName
    }
    ),
    a!textField(
    label: "First Name",
    value: local!lastName,
    /* validations: if(len(local!lastName) > 10, "Number of characters in last name must be less than 10", ""), */
    saveInto: {
    local!lastName
    }
    )
    },
    buttons: a!buttonLayout(
              primaryButtons: {
              a!buttonWidget(
              label: "Submit",
              value: "Submit",
              saveInto: {
                         if(len(local!firstName) > 10,
    a!save(ri!errors_text, append(ri!errors_text, "Number of characters in first name must be less than 10")
    ), {}),
               if(len(local!lastName) > 10,
    a!save(ri!errors_text, append(ri!errors_text, "Number of characters in last name must be less than 10")
    ), {})          
              }
              )}
    )
    )
    )

    It is better to perform save operation on submit button rather than individual fields as there is a chance that user may correct himself in the first attempt itself.

    Please let me know if this is not what you are looking for!
Reply
  • You can use the same expression which is used for validation to save the error messages in a rule input. You can refer the following code for more understanding:

    load(
    local!firstName,
    local!lastName,

    a!formLayout(
    label: "Form",
    firstColumnContents: {
    a!textField(
    label: "First Name",
    value: local!firstName,
    /* validations: if(len(local!firstName) > 10, "Number of characters in first name must be less than 10", ""), */
    saveInto: {
    local!firstName
    }
    ),
    a!textField(
    label: "First Name",
    value: local!lastName,
    /* validations: if(len(local!lastName) > 10, "Number of characters in last name must be less than 10", ""), */
    saveInto: {
    local!lastName
    }
    )
    },
    buttons: a!buttonLayout(
              primaryButtons: {
              a!buttonWidget(
              label: "Submit",
              value: "Submit",
              saveInto: {
                         if(len(local!firstName) > 10,
    a!save(ri!errors_text, append(ri!errors_text, "Number of characters in first name must be less than 10")
    ), {}),
               if(len(local!lastName) > 10,
    a!save(ri!errors_text, append(ri!errors_text, "Number of characters in last name must be less than 10")
    ), {})          
              }
              )}
    )
    )
    )

    It is better to perform save operation on submit button rather than individual fields as there is a chance that user may correct himself in the first attempt itself.

    Please let me know if this is not what you are looking for!
Children
No Data