Failed to evaluate expression

0
Hello,  I have a micrflow calculation which subtracts X number of months from a date a returns that value to an attribute.  It's used in two places, one is on the edit object page, the the other is in the wizard that creates the object. The Edit works perfectly, but the create returns an error. (stack trace below) There is differences between the create and edit. The edit only shows the date view of the entity which has the calculated value as an attribute. However, the created wizard has the entity as a nested dataview, and by association to another entity. Could this be causing this issue? Any help would be much appreciated.  Many thanks,  Garion   Stack Trace: null [User 'MxAdmin' with session id 'fa9fd2e3-d64e-4c4d-a657-81a48dfde9e0' and roles 'Administrator'] -------- com.mendix.core.CoreRuntimeException: An error occurred while executing the action 'DataManagement.CAL_BreakDateNotice'     at com.mendix.basis.objectmanagement.MendixObjectMemberImpl.getValue(MendixObjectMemberImpl.java:211) Caused by: com.mendix.modules.microflowengine.MicroflowException: Failed to evaluate expression, error occurred on line 1, character 1 addMonths($LeaseLicence/BreakDate,-$LeaseLicence/NoticePeriodMonth) ^     at DataManagement.CAL_BreakDateNotice (End : '') Advanced stacktrace:     at com.mendix.languages.mxexpressions.MxExpression.evaluate(MxExpression.scala:21) Caused by: com.mendix.languages.expressions.ExpressionException: java.lang.NullPointerException     at com.mendix.languages.expressions.Expr.evaluate(Expr.java:34) Caused by: java.lang.NullPointerException: null     at java.util.Calendar.setTime(Calendar.java:1770)     at com.mendix.languages.expressions.DateTimeFunctionCallEvaluator.evaluateAddTime(DateTimeFunctionCallEvaluator.java:161)     at com.mendix.languages.expressions.FunctionCallExpr.evaluateExpression(FunctionCallExpr.java:192)     at com.mendix.languages.expressions.Expr.evaluate(Expr.java:30)     at com.mendix.languages.mxexpressions.MxExpression.evaluate(MxExpression.scala:14)     at com.mendix.modules.microflowengine.microflow.impl.EndEvent.setReturnValue$1(EndEvent.scala:18)     at com.mendix.modules.microflowengine.microflow.impl.EndEvent.$anonfun$execute$1(EndEvent.scala:22)     at com.mendix.modules.microflowengine.microflow.impl.ExceptionHandler.executeWithExceptionHandling(ErrorEvent.scala:32)     at com.mendix.modules.microflowengine.microflow.impl.ExceptionHandler.executeWithExceptionHandling$(ErrorEvent.scala:30)     at com.mendix.modules.microflowengine.microflow.impl.EndEvent.executeWithExceptionHandling(EndEvent.scala:9)     at com.mendix.modules.microflowengine.microflow.impl.EndEvent.execute(EndEvent.scala:22)     at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:201)     at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:157)     at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:46)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:79)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:57)     at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:55)     at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:201)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:206)     at com.mendix.basis.component.InternalCore.execute(InternalCore.java:659)     at com.mendix.basis.objectmanagement.MendixObjectMemberImpl.getValue(MendixObjectMemberImpl.java:209)     at com.mendix.webui.jsonserialization.MemberValueConverter$.getValue$1(MemberValueConverter.scala:24)     at com.mendix.webui.jsonserialization.MemberValueConverter$.transformOriginalMemberValue(MemberValueConverter.scala:35)     at com.mendix.webui.jsonserialization.MendixObjectConverter$.convertMemberValue(MendixObjectConverter.scala:71)     at com.mendix.webui.jsonserialization.MendixObjectConverter$.$anonfun$convertForAttributesMatching$3(MendixObjectConverter.scala:58)     at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)     at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:231)     at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:462)     at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)     at com.mendix.webui.jsonserialization.MendixObjectConverter$.convertForAttributesMatching(MendixObjectConverter.scala:57)     at com.mendix.webui.jsonserialization.MendixObjectConverter$.convert(MendixObjectConverter.scala:13)     at com.mendix.webui.requesthandling.RequestHandlingUtil$.$anonfun$getState$default$5$1(RequestHandlingUtil.scala:154)     at com.mendix.webui.requesthandling.RequestHandlingUtil$.$anonfun$getState$10(RequestHandlingUtil.scala:189)     at scala.collection.immutable.List.map(List.scala:283)     at com.mendix.webui.requesthandling.RequestHandlingUtil$.getState(RequestHandlingUtil.scala:189)     at com.mendix.webui.requesthandling.helpers.StateHandling.withState(StateHandling.scala:27)     at com.mendix.webui.requesthandling.helpers.StateHandling.withState$(StateHandling.scala:17)     at com.mendix.webui.requesthandling.ClientRequestHandler.withState(ClientRequestHandler.scala:29)     at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleRequest$1(ClientRequestHandler.scala:185)     at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleRequest$1$adapted(ClientRequestHandler.scala:171)     at com.mendix.webui.requesthandling.helpers.ContextHandling.$anonfun$inContext$4(ContextHandling.scala:41)     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)     at com.mendix.basis.actionmanagement.IMonitoredAction$$anon$1.execute(IMonitoredAction.scala:47)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor(IMonitoredAction.scala:49)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor$(IMonitoredAction.scala:25)     at com.mendix.webui.requesthandling.helpers.ContextHandling$ClientMonitoredAction.monitor(ContextHandling.scala:49)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:41)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:27)     at com.mendix.webui.requesthandling.ClientRequestHandler.inContext(ClientRequestHandler.scala:29)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:24)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:19)     at com.mendix.webui.requesthandling.ClientRequestHandler.inContext(ClientRequestHandler.scala:29)     at com.mendix.webui.requesthandling.ClientRequestHandler.handleRequest(ClientRequestHandler.scala:171)     at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$handleAction$1(ClientRequestHandler.scala:142)     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:142)     at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:102)     at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:40)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:72)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:69)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:75)     at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.java:862)     at com.mendix.m2ee.appcontainer.server.handler.RuntimeHandler.service(RuntimeHandler.java:42)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)     at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)     at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)     at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)     at org.eclipse.jetty.server.Server.handle(Server.java:561)     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334)     at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104)     at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)     at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:243)     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)     at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)     at java.lang.Thread.run(Thread.java:748)  
asked
3 answers
3

The issue lies in the fact that one or both of your inputs for the addMonths function is empty.

Verify the values before this function is triggered with the debugger to see the cause of this issue.

answered
3

If you are using it like this, it is always good to have a handling for empty values in your change action, even if you think it can never happen. Something like this:

if $Date != empty

then addMonths($Date, XXX)

else empty

answered
1

Hi both, thanks for your response.

Is there anyway to "skip over" the error. At this point it makes sense they are empty as this is creating the object. Or am I doing this the complete wrong way. 

Also, Andreas I have looked at you suggestion and but get "missing EOF at 'if' "

answered