How to use aggreate functions in client api

0
Is it possible to use aggreate functions, or query functions in the client api? My goal is to get a sum of a attribute with xpath, based on some user input, the constraint will change for the sum. window.mx.data.get({ xpath: "sum(//MyFirstModule.Ticket[contains(Subject, 'test')]/Number)", callback: function(objs) { console.log("Received " + objs.toString()); } }); This code will thrown the following error: com.mendix.core.CoreRuntimeException: Exception occurred in action '{"xpath":"sum(//MyFirstModule.Ticket[contains(Subject, 'test')]/Number)","amount":-1,"offset":-1,"returnsCount":false,"sort":[],"type":"RetrieveXPathSchemaRawAction"}', all database changes executed by this action were rolled back at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.processErrorState(CoreActionHandlerImpl.scala:151) Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: An exception has occurred for the following request(s): InternalLimitedXPathTextGetRequest (depth = 0): sum(//MyFirstModule.Ticket[contains(Subject, 'test')]/Number) at com.mendix.connectionbus.RequestAnalyzer.doRequest(RequestAnalyzer.java:63) Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: Entity 'Number' not found neither in list of entities MyFirstModule.Ticket nor in their super-type entities at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.verifyMetaObjectName(QueryMapper.java:886) at java.base/java.util.Optional.ifPresent(Optional.java:183) at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.validateSchemaMetaObjectName(QueryMapper.java:879) at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.<init>(QueryMapper.java:120) at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.getQueryInstances(QueryMapper.java:144) at com.mendix.connectionbus.retrieve.OqlRequestHandler.doOldQueryHandling(OqlRequestHandler.scala:175) at com.mendix.connectionbus.retrieve.OqlRequestHandler.handleError$1(OqlRequestHandler.scala:60) at com.mendix.connectionbus.retrieve.OqlRequestHandler.handleRequest(OqlRequestHandler.scala:101) at com.mendix.connectionbus.retrieve.DataStoreCaller.processOqlGetRequest(DataStoreCaller.scala:41) at com.mendix.connectionbus.retrieve.DataStoreCaller.$anonfun$getResult$1(DataStoreCaller.scala:35) at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245) at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36) at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33) at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38) at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245) at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242) at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108) at com.mendix.connectionbus.retrieve.DataStoreCaller.getResult(DataStoreCaller.scala:35) at com.mendix.connectionbus.retrieve.DataStoreCaller.getResult(DataStoreCaller.scala:33) at com.mendix.connectionbus.retrieve.GetRequestHandler.doRequest(GetRequestHandler.java:66) at com.mendix.connectionbus.RequestAnalyzer.doRequest(RequestAnalyzer.java:49) at com.mendix.connectionbus.ConnectionBusImpl.doRequest(ConnectionBusImpl.java:522) at  
asked
1 answers
0

This just looks like Number isn’t part of your Ticket entity, so the XPath is failing for that reason.

answered