Skip to main content
Inspiring
January 10, 2023
Question

Modify a process variable being passed from external API and rerun the process

  • January 10, 2023
  • 1 reply
  • 0 views

Hi,

There is processmodel causing JDBC exception due to long data inputs for STATUS column 

local! externalReq: "resourceName=Employee,employeeDetails=[empId=,empEmail:external@yahoo.in,  status=married,married,married,married , age: 30], companyDetails=, serviceProviderDetails= ",

There is a process model where its receiving some details from external API and for some reason i am getting few duplicate fields in a running process instance .For example: status column in employeeDetails table.

if the resourceName =Employee then there is employeeDetails been received from API and for some reason i am getting status column as duplicated.Expected thig is status=married .

and as the status column has 10 character length in DB ,my process is causing error .

how can I modify the existing payload to this :-   "resourceName=Employee,employeeDetails=[empId=,empEmail:external@yahoo.in,  status=married , age: 30], companyDetails=, serviceProviderDetails= ",

and rerun the existing process instance so it will be saved to DB table .

                          

    1 reply

    prafuls972
    January 10, 2023

    = a!localVariables(
      local!body: a!fromJson(http!request.body),
      local!gender: if(
        index(local!body, "gender", null) = "M",
        "Male",
        "Female"
      ),
      local!dictionary: a!update(local!body, "gender", local!gender),
      a!httpResponse(
        headers: {
          a!httpHeader(
            name: "Content-Type",
            value: "application/json"
          )
        },
        body: a!startProcess(
          processModel: cons!yourProcessmodel,
          processParameters: {
           
            requestJson: local!dictionary,
            
          },
          onSuccess: a!httpResponse(
            statusCode: 200,
            headers: rule!BCO_WEB_createJsonHeader(),
            body: a!toJson(
              {
                code: 0,
                message: "Success",
                details: "The request has been accepted and is being processed",
                referenceId: fv!processInfo.pp.id,
               /* messageId: local!messageId,
                correlationId: local!correlationId*/
              }
            )
          ),
          onError: rule!BCO_WEB_CreateJsonErrorResponse(
            httpStatusCode: 500,
            errors: {
              'type!{urn:com:appian:types:BCO_WEB}BCO_WEBErrorDetails'(
                message: "Technical Error",
                origin_system: "Appian",
                backend_system: "",
                backend_code: "API-1002",
                backend_message: "There was an error starting the process"
              )
            }
          )
        )
      )
    )

    In above mentioned code I have manipulated the gender before calling the process model this way you can manipulate any tag which is coming in the WEB APi. Hope this helps you