Execute a microflow async from javascript, doesnt work in mendix 9
2
Hello everyone, I am in the process of upgrading our project from Mx 8 to Mx 9. In mendix 9, there is a strange error when executing a microflow from javascript. Running a microflow from javascript normally succeeds, but as soon as we want to run the microflow asynchronously, it goes wrong. Function is: function mfCreateLocalStorageValues (showWhatIsNew, cameraInstructiesGezien, taalVoorkeur, hideNieuwsBericht) { mx.data.create({ entity: 'Beheer.LocalStorageValues', callback: function (obj) { obj.set('showWhatIsNew', showWatIsNieuw); obj.set('cameraInstructiesGezien', cameraInstructiesGezien); obj.set('taalVoorkeur', taalVoorkeur); obj.set('hideNieuwsBericht', hideNieuwsBericht); mx.ui.action('Beheer.CDV_LocalStorageValues_Use',{ params: { applyto: 'selection', guids: [obj.getGuid()] }, progress: 'modal', progressMsg: messages.MENDIX_PROGRESS_MESSAGE_LOCALSTORAGE, async: true, callback: function () { console.log('Microflow successfully executed'); navigator.splashscreen.hide(); navigationService.navigateToPage('mendix'); }, error: function (error) { console.error('Error executing Microflow: ' + error); } }); }, error: function (error) { console.error('Error when creating mxObject: ' + error); } }); } Mendix error: com.mendix.core.CoreException: com.mendix.systemwideinterfaces.MendixRuntimeException: Unsupported value: Beheer.LocalStorageValues@82190693199512755 (class com.mendix.basis.value.ObjectValue) at com.mendix.basis.component.ExecutionCore.executeAsyncScala(ExecutionCore.scala:120) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Unsupported value: Beheer.LocalStorageValues@82190693199512755 (class com.mendix.basis.value.ObjectValue) at com.mendix.basis.value.MendixValue$.apply(MendixValue.scala:85) at com.mendix.basis.action.CustomActionFactory.$anonfun$createUserAction$1(CustomActionFactory.scala:48) at scala.collection.immutable.ArraySeq.$anonfun$map$1(ArraySeq.scala:71) at scala.collection.immutable.ArraySeq.$anonfun$map$1$adapted(ArraySeq.scala:71) at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:286) at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:265) at scala.collection.ClassTagIterableFactory$AnyIterableDelegate.tabulate(Factory.scala:679) at scala.collection.immutable.ArraySeq.map(ArraySeq.scala:71) at com.mendix.basis.action.CustomActionFactory.createUserAction(CustomActionFactory.scala:48) at com.mendix.basis.component.ExecutionCore.executeAsyncScala(ExecutionCore.scala:115) at com.mendix.basis.component.ExecutionCore.executeAsyncScala$(ExecutionCore.scala:110) at com.mendix.basis.component.InternalCore.executeAsyncScala(InternalCore.scala:23) at com.mendix.webui.actions.client.ExecuteActionAction.execute(ExecuteActionAction.java:164) at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleRequest$2(ClientRequestHandler.scala:167) at com.mendix.webui.requesthandling.helpers.StateHandling.withState(StateHandling.scala:42) at com.mendix.webui.requesthandling.helpers.StateHandling.withState$(StateHandling.scala:39) at com.mendix.webui.requesthandling.ClientRequestHandler.withState(ClientRequestHandler.scala:29) at com.mendix.webui.requesthandling.helpers.StateHandling.withState(StateHandling.scala:36) at com.mendix.webui.requesthandling.helpers.StateHandling.withState$(StateHandling.scala:29) at com.mendix.webui.requesthandling.ClientRequestHandler.withState(ClientRequestHandler.scala:29) at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleRequest$1(ClientRequestHandler.scala:165) at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleRequest$1$adapted(ClientRequestHandler.scala:151) at com.mendix.webui.requesthandling.helpers.ContextHandling.$anonfun$inContext$5(ContextHandling.scala:57) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) at com.mendix.basis.actionmanagement.ActionMonitoring$.$anonfun$monitor$1(ActionMonitoring.scala:49) at com.mendix.util.classloading.Runner.withContextClassLoader(Runner.java:19) at com.mendix.basis.actionmanagement.ActionMonitoring$.monitor(ActionMonitoring.scala:49) at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:57) at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:31) at com.mendix.webui.requesthandling.ClientRequestHandler.inContext(ClientRequestHandler.scala:29) at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:28) at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:20) at com.mendix.webui.requesthandling.ClientRequestHandler.inContext(ClientRequestHandler.scala:29) at com.mendix.webui.requesthandling.ClientRequestHandler.handleRequest(ClientRequestHandler.scala:151) at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleAction$1(ClientRequestHandler.scala:123) at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest(ProfileHandling.scala:14) at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest$(ProfileHandling.scala:10) at com.mendix.webui.requesthandling.ClientRequestHandler.profileRequest(ClientRequestHandler.scala:29) at com.mendix.webui.requesthandling.ClientRequestHandler.handleAction(ClientRequestHandler.scala:123) at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:79) at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:35) at com.mendix.external.connector.MxRuntimeConnector.lambda$processRequest$0(MxRuntimeConnector.java:74) at com.mendix.util.classloading.Runner.withContextClassLoader(Runner.java:19) at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:73) at com.mendix.basis.impl.MxRuntimeImplBase.processRequest(MxRuntimeImplBase.java:838) at com.mendix.m2ee.appcontainer.server.handler.RuntimeServlet.service(RuntimeServlet.scala:25) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626) at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:228) at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) at org.eclipse.jetty.server.Server.handle(Server.java:516) at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388) at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:386) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) at java.base/java.lang.Thread.run(Thread.java:834) In mendix 8 the same functions works fine. Does anyone know what could be causing this?
asked
Matthijs Roukema
3 answers
1
The default value of async flag in Javascript/AJAX calls is true. You can specify it false as per requirement.
The microflow works perfectly fine if we do not specify "async: true" - Even in that case, the async flag will be treated as true as it is
answered
Max Draijer
0
Hi Matthijs,
It seems that the override for executeAsync without the third (parameter boolean executeInTransaction) has been removed from Core. You now need to supply four parameters