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
  • Is this behaviour totally uncertain or is it for some conditional flow? Make sure that all the nodes between Start node and attended task are properly chained.

    You need to confirm that the task is actually active by the time you are preparing response in API, for troubleshooting you can create another flow which will add some delay to a!startProcess() returning in API. Check if the task URL is getting generated everytime now?

    Another possibility could be that the Task Report is not getting refresh instantly and queryProcessAnalytics is unable to get the taskId, you can try getactivetaskidsforprocess() function available in Task Management Smart Services plugin to get the taskId if that helps.

Reply
  • Is this behaviour totally uncertain or is it for some conditional flow? Make sure that all the nodes between Start node and attended task are properly chained.

    You need to confirm that the task is actually active by the time you are preparing response in API, for troubleshooting you can create another flow which will add some delay to a!startProcess() returning in API. Check if the task URL is getting generated everytime now?

    Another possibility could be that the Task Report is not getting refresh instantly and queryProcessAnalytics is unable to get the taskId, you can try getactivetaskidsforprocess() function available in Task Management Smart Services plugin to get the taskId if that helps.

Children