How can I get the process instance errors and save it into any process variable?

Dear community,

I have a start process web api, the process is updating the metadata table.

My facing issue is that API response success even when write to data store entity error.

The expected result should be when process executing error, we can expose the process instance error in web api response body.

Therefore, how can I get the process instance error? then I can save it into process variable, and in the api, we can get it through ProcessInfo.

Thanks in advance for your answers.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi,

    can you please try with this code 

    a!startProcess(
    processModel: cons!Process_model,
    processParameters: a!fromJson(
    http!request.body
    ),
    onSuccess: a!writeToDataStoreEntity(
    dataStoreEntity: cons!Datastoreentity,
    valueToStore: {},
    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 recived while inserting data"
    }
    )
    )
    ),
    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"
    }
    )
    )
    )

    please user a!writetodatastore smartservice on success of a!startprocess and the error will be received in case failed

Reply
  • 0
    Certified Senior Developer

    Hi,

    can you please try with this code 

    a!startProcess(
    processModel: cons!Process_model,
    processParameters: a!fromJson(
    http!request.body
    ),
    onSuccess: a!writeToDataStoreEntity(
    dataStoreEntity: cons!Datastoreentity,
    valueToStore: {},
    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 recived while inserting data"
    }
    )
    )
    ),
    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"
    }
    )
    )
    )

    please user a!writetodatastore smartservice on success of a!startprocess and the error will be received in case failed

Children
No Data