WEB API response not updating the process variable

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? 

  Discussion posts and replies are publicly visible

Parents
  • Hi  and  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"
    } ]
  • +1
    Certified Lead Developer
    in reply to radhikam0005

    Hi ,

    If your response is returned like this and in the process the case id's are present as expected, then you are running out of activity chained nodes. At any time, max of 50 chained nodes can be executed and then activity chaining would by default break but the process would continue.

    You can read it over here: https://docs.appian.com/suite/help/20.1/Process_Model_Recipes.html#breaking-a-chain

    You can follow the approach Stewart has suggested below, I would prefer that as well.

    If you want to not use stored procedure, save blank rows in your database to generate new id's in your table and then update the ID accordingly in your loop to map the ID's.

    if your case creation scenario is more complicated and creating ID's upfront doesn't look feasible I would suggest to restrict one  case creation at once or remove looping and create a logic which allows writing multiple rows at once.

  • You guys are correct activity chaining is passing 50 nodes. I will consider redesigning the process model in such a way that I get all the case ids at once instead of getting them one by one out of the loop. Thank you for suggesting the solution. 

    Can you little bit elaborate about the stored procedure? What it should be doing?

Reply Children
  • 0
    Certified Lead Developer
    in reply to radhikam0005

    The idea is to get case id's generated at once. You can do that by writing INSERT statements on your table through a stored procedure. The same can be done via write to data store where you could initially write blank rows to get case id's (I assume you are creating them using auto increment primary ID of your table)

    Once you get the generated Id's (either via stored procedure / process), you can use them to map it in your loop to individual case and populate the remaining details in your table.