Invalid JSONRequest error when calling a Microflow from a Nanoflow

0
  Hi,   Im fairly new to Mendix so pardon me if Im missing something obvious here, but Im getting the following error when Im calling a Microflow from a Nanoflow: Invalid JSONRequest JSONObject["value"] not found. The basic logic I’ve implemented is, on-click of a button; Run a Nanoflow in order to collect some data (external API calls + selected objects in the UI) Fill out a selected FileDocument with the collected data. The main/parent Nanoflow is divided up into 2 “sub-flows”, the data-collection (Nanoflow with JavaScript and other “sub-flows”) and the FileDocument modifications (Microflow). The data collection part seems to work fine, it returns a list of “Updates” (fieldnames and values) that are to be made to a document. But when I call the Microflow in order to update the FileDocument I get the following 2 errors: Invalid JSONRequest JSONObject["value"] not found. [User 'MxAdmin' with session id 'e1a8e85e-XXXX-XXXX-XXXX-XXXXXXXX6531' and roles 'Administrator'] com.mendix.thirdparty.org.json.JSONException: JSONObject["value"] not found.     at com.mendix.thirdparty.org.json.JSONObject.get(JSONObject.java:469)     at com.mendix.webui.jsonserialization.IncomingObject$.$anonfun$parse$1(IncomingObject.scala:20)     at scala.collection.immutable.List.map(List.scala:246)     at scala.collection.immutable.List.map(List.scala:79)     at com.mendix.webui.jsonserialization.IncomingObject$.parse(IncomingObject.scala:19)     at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.$anonfun$apply$2(RegularClientAction.scala:50)     at scala.collection.immutable.List.map(List.scala:246)     at scala.collection.immutable.List.map(List.scala:79)     at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.apply(RegularClientAction.scala:50)     at com.mendix.webui.actions.client.RegularClientAction$Helpers$StateHandler.apply(RegularClientAction.scala:46)     at com.mendix.webui.actions.client.ExecuteMicroflowAction.apply(ExecuteMicroflowAction.scala:43)     at com.mendix.webui.actions.client.ExecuteMicroflowAction.apply(ExecuteMicroflowAction.scala:22)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$3(RegularClientAction.scala:113)     at scala.util.Try$.apply(Try.scala:210)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2(RegularClientAction.scala:113)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2$adapted(RegularClientAction.scala:111)     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.scala:20)     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.actions.client.RegularClientAction.inContext(RegularClientAction.scala:87)     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.actions.client.RegularClientAction.inContext(RegularClientAction.scala:87)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$1(RegularClientAction.scala:111)     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)     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.actions.client.RegularClientAction.profileRequest(RegularClientAction.scala:87)     at com.mendix.webui.actions.client.RegularClientAction.execute(RegularClientAction.scala:108)     at com.mendix.webui.requesthandling.ClientRequestHandler.handleAction(ClientRequestHandler.scala:106)     at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:79)     at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:37)     at com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1(MxRuntimeConnector.scala:50)     at com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1$adapted(MxRuntimeConnector.scala:50)     at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)     at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.scala:50)     at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.scala:223)     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:1631)     at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:230)     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:1440)     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:1355)     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:487)     at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)     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:409)     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) Invalid JSONRequest JSONObject["value"] not found. Error: Invalid JSONRequest JSONObject["value"] not found. at h (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:15851) at async http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:4404 at async a (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:14225) at async d (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:15348) at async h.executeMicroflow (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:66:25372) at async S.execute (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:91015) at async Object.executeInstructions (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:109045) at async le.insideNewStack (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:106331) at async Object.execute (http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:108246) at async http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:66:6667   When I try to commit the FileDocument that I use as parameter for the Microflow before calling it I get a similar error: An error occurred while executing microflow data source for widget MainModule.MainPage.gallery2: Invalid JSONRequest JSONObject["value"] not found. Error: An error occurred while executing microflow data source for widget MainModule.MainPage.gallery2: Invalid JSONRequest JSONObject["value"] not found. at http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:165861 at http://localhost:8080/mxclientsystem/mxui/mxui.js?637944453220693920:68:166002  Oddly enough “MainModule.MainPage.gallery2” is where you select which FileDocument you wish to update, but when i debug the flow all the information seems to be available.   I have a feeling that the issue has to do with the commit in both cases, but an auto-commit before the microflow call in the first case. I could be wrong though. Feel free to ask any questions, I’ve tried to summarize and simplify a fairly extensive chain of flows and have surely been slightly unclear in the process. Any help would be greatly appreciated though!   Many thanks in advance!   
asked
3 answers
0

A JSON Object should start with {. A JSON list start with [

Maybe that is already a clue. If not, can you add some screenshots of the flows you created?

answered
0

@Tim van Steenbergen,

 

The screenshot as promissed:

answered
0

I seem to have solved the issue, not sure about the root cause though. If someone knows the inner workings of Mendix, perhaps they can fill something in, but otherwise there might be a bug hidden somewhere.

 

The “Insurance” entity is an impersistent entity with data retrieved from an external API. The user can select which Insurance to get data from in a list in the UI. In my flows I take the selected insurance and work with it, along with data from other sources, in a JavaScript-file. In order to more simply work with the data I create a master object in the js-code, for example, an individuals insurance (2 sources) will be found via Contact.Insurance. 

From what I can see the impersistent Insurance object was substituted with my modified JS version causing a crash. I cant really figure out how the system would “confuse” the two.

I changed how I iterate over the provided objects and “build” the master which made it work. 
Does modifying an object, for example deleting an attribute or similar, in JS cause it to change the “actual” object?

The master object is returned as a string (workaround to pass a JSON from one place to the next) from the JS/Nanoflow, and is used as an argument for another JS, so surely Mendix cant do anything odd with that info.

If this interests someone, feel free to chime in. Otherwise I’d just like to say that the issue has been resolved. When I get the time Ill look into this further to understand how Mendix works.


If you notice something Im doing incorrectly or in a sub-optimal manner, please let me know. Anything that can improve my Mendix skills is highly appreciated.
 

Thanks!

answered