Start process via API and put task URL in the response

Certified Associate Developer

Hi guys,

we have the requirement to start an Appian process via API from an external system and redirect the user to the url of the first task of that process. I tried to achieve this in the following way.

We created a process model and activity-chained the first user input task with the start node. Then we created a POST api and start the process with a!startProcess and we valued the onSuccess parameter of that rule like this:

a!httpResponse(
statusCode: 200,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson({
taskUrl: a!urlfortask(
index(rule!LM_getTaskDetailsByPid(
pid: index(index(fv!processInfo, "pp", null), "id", null)
), "taskId", null)
)
})
)

where rule!LM_getTaskDetailsByPid is a rule that, given a process id, retrieves the id of the active task of the process in the taskId component using a task report and query analytics.

Unfortunately we noticed that sometimes this fails because the system tries to evaluate LM_getTaskDetailsByPid before the process has reached the user input task!

How could we achieve this in a safe way?

Thank you to anyone could help us!

Lorenzo

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data