Skip to main content
January 10, 2023
Solved

Call the integration in the interface

  • January 10, 2023
  • 3 replies
  • 0 views

Hello Appian People,

I have integration GET(Queries Data). Basically this integration search address.

And I call this integration in the interface. In my interface I have a texbox and search button,

whenever the search button is clicked if there is corresponding search result returned in the integration or

if the integration search result is onSuccess the result value will print.

So my problem is, how to check if  the result of the integration in the interface  fails/failure and gets the corresponding message

of the integration error?

Best answer by jonesprakashs0001

Hi, I have used the following API to implement the above (http://www.postalpincode.in/Api-Details). Hope this helps.

a!localVariables(
  local!pinCode,
  local!integrationResult,
  local!isintegrationSuccess,
  {
    a!sectionLayout(
      label: "Find the post offices by Pin Code",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "",
                  labelPosition: "ABOVE",
                  value: local!pinCode,
                  saveInto: { local!pinCode },
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "SEARCH",
                      style: "NORMAL",
                      saveInto: {
                        a!save(
                          local!integrationResult,
                          rule!JPS_INT_getDetailsByPostCode(pinCode: local!pinCode)
                        ),
                        a!save(
                          local!isintegrationSuccess,
                          and(
                            toboolean(
                              index(local!integrationResult, "success", null)
                            ) = true(),
                            tointeger(
                              index(
                                local!integrationResult,
                                "statusCode",
                                null
                              )
                            ) = 200
                          )
                        )
                      }
                    )
                  },
                  align: "START"
                )
              }
            ),
            a!columnLayout(contents: {})
          }
        )
      }
    ),
    a!richTextDisplayField(
      value: {
        a!richTextItem(
          text: local!integrationResult.result.message,
          color: "NEGATIVE",
          showWhen: local!isintegrationSuccess
        ),
        a!richTextBulletedList(
          items: local!integrationResult.result.body.PostOffice.Name,
          showWhen: not(local!isintegrationSuccess)
        )
      },
      showWhen: a!isNotNullOrEmpty(local!integrationResult)
    )
  }
)

3 replies

January 10, 2023

 An integration will be considered successful if the system returns a status code of 200

please check the value in the interface - fv!result.statusCode = 200, the it will be success or else it is failed and we have to figure out what is the issue.

jonesprakashs0001
January 10, 2023

Hi, I have used the following API to implement the above (http://www.postalpincode.in/Api-Details). Hope this helps.

a!localVariables(
  local!pinCode,
  local!integrationResult,
  local!isintegrationSuccess,
  {
    a!sectionLayout(
      label: "Find the post offices by Pin Code",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "",
                  labelPosition: "ABOVE",
                  value: local!pinCode,
                  saveInto: { local!pinCode },
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "SEARCH",
                      style: "NORMAL",
                      saveInto: {
                        a!save(
                          local!integrationResult,
                          rule!JPS_INT_getDetailsByPostCode(pinCode: local!pinCode)
                        ),
                        a!save(
                          local!isintegrationSuccess,
                          and(
                            toboolean(
                              index(local!integrationResult, "success", null)
                            ) = true(),
                            tointeger(
                              index(
                                local!integrationResult,
                                "statusCode",
                                null
                              )
                            ) = 200
                          )
                        )
                      }
                    )
                  },
                  align: "START"
                )
              }
            ),
            a!columnLayout(contents: {})
          }
        )
      }
    ),
    a!richTextDisplayField(
      value: {
        a!richTextItem(
          text: local!integrationResult.result.message,
          color: "NEGATIVE",
          showWhen: local!isintegrationSuccess
        ),
        a!richTextBulletedList(
          items: local!integrationResult.result.body.PostOffice.Name,
          showWhen: not(local!isintegrationSuccess)
        )
      },
      showWhen: a!isNotNullOrEmpty(local!integrationResult)
    )
  }
)

January 11, 2023

Hi Jones,

This helped, Thanks a lot