I am using a!startProcess in a Web API.
In the process model, I have a Write to Data Store Entity service that saves the output to a process variable.
However, when I access the process variable in a!startProcess onSuccess through fv!processInfo.pv, the value of the process variable is not updated--specifically, the ID field is blank.
Any advice on how I can get the updated value of the process variable?
Discussion posts and replies are publicly visible
@jraquino I guess in your process model somewhere you are using write to data store entity smart service. Go to node outputs and save the CDT back. If you do this your primary key/id will be updated. You can access the same using fv!processInfo.pv. Keep in mind activity-chaining is complete.
This smart service follows activity-chaining, completing only when the activity chain is complete or broken. The smart service then returns the process variables as of the completion of activity chaining through the processInfo.pv output.
Hi jraquino (johnraphaela0001) as per my understanding, when you use a!startProcess(), this initiates an instance of a process Asynchronously, that means it won't wait till the completion of the entire process, hence your ID field is getting Blank/Empty/null
As per the documentation, this follows activity-chaining, completing only when the activity chain is complete or broken. This returns the process variables as of the completion of activity chaining through the processInfo.pv output.
So as per your requirement, you need to start the process Synchronously so that you can get the ID returned as the response, so here i can suggest 2 ways to handle this scenario.
1. Expose this Process model as Service, then try invoking this service using Synchronous Process Model Web Service Shared Component, this will return the complete process data including the process Variables.
2. If you don't want to expose the Process as Service(Mention in Point-1), then try Chaining the nodes till Write to Data Store Entity Node, of the process model, and check whether are you getting the process Variable value or not, if no, then you can design a complex Process model to achieve this, where you will have AND gateway, followed by a XOR, which will check whether fv!processInfo.pv.myCDT.id is empty or not, if yes then keep on looping till, this do not gets the value, and the other flow of AND will be going towards the Write to Data Store Entity Node.
Once the XOR condition Satisfies, you can show the desired response on the screen to the End USER.
But i feel, it's(Approach-2) a very Complex, Iterative & Time Taking approach and may cause performance issue as well.
So i feel, going for the 1st Option will be the better choice.
Hope this will help you.
Hi Kondativ, I see EXACTLY WHY you did this in BOLD LETTERS... :-)
© 2022 Appian. All rights reserved.