Parameter empty when passing Map to executeAsync

1
I have a java action which accepts Objects of type EmergencyPage.EmergencyCall. The JavaAction is also in Module EmergencyPage. When calling the action and passing an object of type EmergencyCall the Object can be logged in the action. But when asynchronously calling a microflow and passing the object as map it is empty. This is the action: log.info("EmergencyCall: " + EmergencyCall.toString()); java.util.Map<String, Object> map = new java.util.HashMap<String, Object>(); map.put("EmergencyPage.EmergencyCall", this.EmergencyCall); log.info("Map: " + map.toString()); com.mendix.core.Core.executeAsync(this.context(), "EmergencyPage.ProcessEmergencyCall", true, map); These are the log entries: 2020-06-19 16:56:14.397EmergencyCallEmergencyCall: emergencypage.proxies.EmergencyCall@c7957ca3 2020-06-19 16:56:14.398EmergencyCallMap: {EmergencyPage.EmergencyCall=emergencypage.proxies.EmergencyCall@c7957ca3} I have a breakpoint in the ProcessEmergencyCall Microflow, which is triggered but the Parameter Object is empty. What do I have to do, to help the object not to get lost?
asked
2 answers
2

The key should match the parameter name in the microflow, e.g:
map.put("EmergencyCall", this.EmergencyCall);
-Andrej

--EDIT—
Perhaps it helps to convert back the proxy object to a mendix object
map.put("EmergencyCall", this.EmergencyCall.getMendixObject());

answered
1

Hello Max, 

One scenario what I can think of can lead to this situation is:

  1. When you have created the object but not saved. So it is still in memory. 
  2. When you are sending these kind of objects, remember these objects exists in User context.
  3. When executing the MF as Asynchronous, it will run in System context, so the object created in User context will not be accessible.
  4. But the same MF when run in Synchronous mode, it will perfectly fine, as it will be running in User context.
  5. Please check if you are facing the above situation.

 

You could possibly solve this by passing some kind of unique ID of the object and retrieve the object from DB using that ID. Or may be try ProcessQueue module if you want to run things in Background. Also check how executeMicroflowInBackground or some similar Microflows are implemented in communitycommons.

I also faced this same situation. Hope this helps.

Regards,

Nirmal

answered