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

Certified Associate Developer

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 .

                          

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    = 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

Reply
  • 0
    Certified Senior Developer

    = 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

Children
No Data