If you used the template for starting a process model via webapi you'll see that the onSuccess parameter is evaluated when the process kicks off successfully. However, the onSuccess also won't evaluate until the chain completes within a process. What this allows you to do is chain a number of nodes together starting with the beginning of your process model and at certain points update a process variable with the progress. Then using the function variable fv!processInfo you'll be able to use the values of these process variables in the onSuccess parameter. Documentation is here https://docs.appian.com/suite/help/20.4/Start_Process_Smart_Service.html#a!startprocess(). Using those variables you can return different status codes.
Please remember that by chaining your process this will cause Appian to prioritize executing those nodes. Also, if you have a lot of nodes this means your webapi request time will be slower.
Does this help?
a!startProcess(
processModel: cons!PROCESS_MODEL,
processParameters: a!fromJson(
http!request.body
),
onSuccess: {
if(
fv!processInfo.pv.finishedAllNodes,
a!httpResponse(
statusCode: 200,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
fv!processInfo
)
),
a!httpResponse(
statusCode: 205,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
{
error: "Process started but not all nodes completed successfully"
}
)
)
)
},
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"
}
)
)
)