How to validate form based on integration result

we have an interface where we are call an integration (passing data provided by the user in that interface) on submit button.

If integration got failed, then we need to display a validation message on one of the text field in the interface. else if it got succeeded then form has to submit.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You have multiple options. The straight forward one is to add another user input task to your process model and add a XOR in the path checking the result of the integration. If the integration fails, go to the new task. Make sure to enable chaining on all connectors between the first task and the new one. The new added task can show that error message to the user.

    Depending on your needs you can allow the user to modify the data and retry.

  • I am looking to validate with in the same interface instead of moving to another one

  • 0
    Certified Lead Developer
    in reply to sureshk

    Hi Suresh,

    If you want to call and validate the service response at Submit button and you don't want to proceed to next interface in case of failure, i think we need to put validation rules so that when service has failed it should not allow form to be submitted.

    You could try to implement below logic, to stop form being submitted in case of service failure:

    a!localVariables(
    local!success: {},
    {
    a!sectionLayout(
    contents: {
    a!textField(
    label: "Service Input",
    value: ri!integrationInput,
    saveInto: ri!integrationInput,
    validations: if(
    local!success,
    {},
    "Service Failure Message"
    )
    ),

    },

    ),
    a!buttonArrayLayout(
    buttons: {a!buttonWidget(
    label: "Submit",
    style: "PRIMARY",
    saveInto: {
    a!save(
    local!success,
    rule!integrationCall(
    ri!integrationInput
    ).success
    )
    },
    submit: true,
    validate: true
    )}
    )}

Reply
  • 0
    Certified Lead Developer
    in reply to sureshk

    Hi Suresh,

    If you want to call and validate the service response at Submit button and you don't want to proceed to next interface in case of failure, i think we need to put validation rules so that when service has failed it should not allow form to be submitted.

    You could try to implement below logic, to stop form being submitted in case of service failure:

    a!localVariables(
    local!success: {},
    {
    a!sectionLayout(
    contents: {
    a!textField(
    label: "Service Input",
    value: ri!integrationInput,
    saveInto: ri!integrationInput,
    validations: if(
    local!success,
    {},
    "Service Failure Message"
    )
    ),

    },

    ),
    a!buttonArrayLayout(
    buttons: {a!buttonWidget(
    label: "Submit",
    style: "PRIMARY",
    saveInto: {
    a!save(
    local!success,
    rule!integrationCall(
    ri!integrationInput
    ).success
    )
    },
    submit: true,
    validate: true
    )}
    )}

Children