Skip to main content
sunus0001
November 19, 2021
Solved

How can i pass multiple process parameter to the process model from the webapi

  • November 19, 2021
  • 2 replies
  • 0 views

HI Appian,

I have to pass multiple cdt values as process parameter from a webapi how can i do that?

Please someone  help me for this. I have attached the sample code for your reference.PF_Request and PF_REQUESTITEMDETAIL is the table which i am passing as parameter from webapi to  process model as Process variables.

a!startProcess(
  processModel: cons!PF_Create_Request_WithChanges,
  processParameters: {
    PF_Request : a!fromJson(
      http!request.body
    ),
    PF_REQUESTITEMDETAIL:a!fromJson(
      http!request.body
    )
  },
  onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
      a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
      fv!processInfo
    )
  ),
  onError: a!httpResponse(
    statusCode: 500,
    headers: {
      a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
      {
        error: "There was an error starting the process"
      }
    )
  )
)

Thanks

Sunu Sam

Best answer by danny.verb

Web API expressions are just like other expressions in Appian in that they can utilize local variables! For example:

a!localVariables(
    local!body: http!request.body,
    local!pfRequest: local!body.pfRequest,
    local!detail: local!body.requestDetail,
    a!startProcess(
      processModel: cons!PF_Create_Request_WithChanges,
      processParameters: {
        PF_Request : local!pfRequest,
        PF_REQUESTITEMDETAIL: local!detail
      },
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          fv!processInfo
        )
      ),
      onError: a!httpResponse(
        statusCode: 500,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          {
            error: "There was an error starting the process"
          }
        )
      )
    )
)

2 replies

danny.verb
November 19, 2021

Web API expressions are just like other expressions in Appian in that they can utilize local variables! For example:

a!localVariables(
    local!body: http!request.body,
    local!pfRequest: local!body.pfRequest,
    local!detail: local!body.requestDetail,
    a!startProcess(
      processModel: cons!PF_Create_Request_WithChanges,
      processParameters: {
        PF_Request : local!pfRequest,
        PF_REQUESTITEMDETAIL: local!detail
      },
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          fv!processInfo
        )
      ),
      onError: a!httpResponse(
        statusCode: 500,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          {
            error: "There was an error starting the process"
          }
        )
      )
    )
)

sunus0001
sunus0001Author
November 19, 2021

HI,

Thank you [emoticon:c4563cd7d5574777a71c318021cbbcc8] got it.