Skip to main content
June 7, 2022
Solved

WEB API response not updating the process variable

  • June 7, 2022
  • 11 replies
  • 0 views

I have one web api which is using a!startProcess to call the process async. As it is async and does not wait for process model to complete it is not updating the process variables in the response. 

What are the possible fixes we can do? 

Best answer by stewart.burchell

Kind of. Separate the generation of the CaseIds from the creation of the Cases themselves. I presume you're generating some human friendly readable CaseId. Create the number that you need (you could use a Stored Procedure to do this to ensure that any concurrent API requests don't overlap), return them to the Process and hand them out to the sub process instances as required to use.

11 replies

agamb0001
June 7, 2022

Apply activity chaining till the point your process variable is updated.

API will capture the response till it's activity chained from the start event.

See documentation for more details

[View:https://docs.appian.com/suite/help/20.1/Start_Process_Smart_Service.html]

stewart.burchell
June 7, 2022

https://docs.appian.com/suite/help/22.2/Start_Process_Smart_Service.html

Read the section on "Leveraging activity-chaining"

June 7, 2022

Hi [mention:d8b421a354554ef089fa196070da6bf2:e9ed411860ed4f2ba0265705b8793d05] and [mention:7628077af4b9463e9533a897fad2351f:e9ed411860ed4f2ba0265705b8793d05] I have activity chaining but we have loop there.  I will explain the scenario in detail, consider we are creating 5 different cases in appian application sent from the external system. There is one process variable of type array which has 5 cases to create and for each one a loop will run inside the process we called from the API. In the response I need all the 5 case ids to be returned but it is returning 2 of them as nulls. 

It would not have returned any of the case ids if activity chaining was not there.
I suppose it is happening because process runs async and as we have loop the process variable is updated but before the 4th 5th iteration completes it returned the response.

"cases" : [ {
"caseId" : 375,
"status" : "CREATED"
}, {
"caseId" : 376,
"status" : "CREATED"
}, {
"caseId" : 377,
"status" : "CREATED"
}, {
"caseId" : null,
"status" : "CREATED"
}, {
"caseId" : null,
"status" : "CREATED"
}, {
"caseId" : null,
"status" : "CREATED"
} ]
stewart.burchell
June 7, 2022

What is your loop doing? Could you create 5 CaseIds in an Expression Rule (called from a single Script Task node)?

June 7, 2022

No for each case we need to start a sync sub process which in turn creates the case and creates the history of the case and then returns the case id back to the parent process model.