refresh / access a non-committed object which got changed in an async microflow

0
Hi, I have a followup question to one I asked before.   I have a situation where initialize a Request object partially and return it to the user in the frontend where he populates it using a multi step wizard. Before returning to the user I invoke a java action which starts an async microflow in the same context to finish the initialization process: HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("Request", __Request); Core.executeAsync(this.getContext(), MicroflowName, false, parameters); The goal is that the initialization process is done until the user enters the 2nd step on the wizard. The async microflow gets called, I perform the initialization, everything good so far. To move to the 2nd page of the wizard the user invokes a microflow. I set a breakpoint and investigated some more. The request I receive seems to be the same (same id) but does not have the same data. Which is to be expected I guess, because how would the frontend know what happened in the backend… I tried several approaches to access the modified Request once I receive the callback from the user to proceed.    Approach 1: Core.retrieveId(this.getContext(), __Request.getId()); I figured it might help if I perform a fresh retrieve using the id of the Request, but it still is the same object.   Approach 2: Core.retrieveByPath(getContext(), __User, "RequestFulfilment.Request_User", true); A non-committed Request is associated to the current user. I tried to perform an ‘in-memory retrieve’ starting from the current user. Still same result.   Approach 3: Core.retrieveByPath(getContext(), __Request, "DynamicData.Position_Request", true); And finally I figured I might as well try to only retrieve the associated items  I’m interessted in, but this doesn’t work either. Note: when I commit the objects they are available once the postback happens. But committing isn’t an option in this case.     I’m running out of ideas. As far as I am aware, object which are not committed are ‘stored’ in the frontend until persistance happens, is this correct? What happens to the Request I modified in the async microflow? Does it still exist? Can I retrieve it? Is it overridden by the retrieve which comes from the fronend?
asked
1 answers
1

If the async microflow commits objects to the database you have the situation that the object in the database can have different values then the one that is still used by the user. So you would need to update those objects by retrieving them from database again.

But my gut feeling is that you are approaching it the wrong way. Could you elaborate on why you need the Java action? Because that part is not clear to me. And is that a custom Java action or the community commons one?

If the reason for the Java action is to inmediately update the database a commit in seperate database transaction would suffice.

Regards,

Ronald

 

answered