How to solve reference set selection to a data grid with aggregation function?

0
Hello All, I have a transport request NewEdit page, where a PremiumRequest object is created. This PremiumRequest entity has many-to-many association with a RequestPackage entity. On the NewEdit page I would like to select multiple RequestPackage objects to a reference set and place the selection in a data grid, where I can use aggregation functions on columns (count, sum) . The problem is, that aggregation can only be used in a grid, if the data source is XPath. I have tried with creating an input reference set selector. I created a data grid with RequestPackage as entity and XPath datasource, with the following constraint (exist-expression): [MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest] The grid does not display the selected references. Could you please help me how to solve this problem?
asked
5 answers
2

you should use the following XPath:

[MyFirstModule.PremiumRequest_RequestPackage = '[%CurrentObject%]']

The XPath you are using is returning all RequestPackages which have ARE referenced by A PremiumRequest

answered
0

Unfortunately this does not work. I attached a picture. You can see, that the referenced objects are selected, but the data grid didn't seems to get the objectsUnfortunately this does not work. I attached a picture. You can see, that the referenced objects are selected, but the data grid didn't seems to get the objects...

 

answered
0

When I try [MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '[%CurrentObject%]'] I get an exception:
An error has occurred while handling the request. [User 'uidn6797' with session id '0691f36e-XXXX-XXXX-XXXX-XXXXXXXXb6b6' and roles 'Administrator']

--------

com.mendix.core.CoreRuntimeException: Exception occurred in action '{"xpath":"//MyFirstModule.RequestPackage[MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '28428972647777557']","amount":20,"offset":0,"returnsCount":true,"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 = -1, amount = 20): //MyFirstModule.RequestPackage[MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '28428972647777557']
    at com.mendix.connectionbus.RequestAnalyzer.doRequest(RequestAnalyzer.java:63)

Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: 'MyFirstModule.PremiumRequest_RequestPackage' is not a valid entity type., exception occurred on mapping the following query: SELECT x1MyFirstModule.RequestPackage.ID FROM MyFirstModule.RequestPackage AS x1MyFirstModule.RequestPackage INNER JOIN x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage AS j1myfirstmodule$premiumrequest_requestpackage WHERE x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '28428972647777557', exception occurred on mapping the following query: SELECT MyFirstModule.RequestPackage/* FROM MyFirstModule.RequestPackage WHERE MyFirstModule.RequestPackage.ID IN (SELECT x1MyFirstModule.RequestPackage.ID FROM MyFirstModule.RequestPackage AS x1MyFirstModule.RequestPackage INNER JOIN x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage AS j1myfirstmodule$premiumrequest_requestpackage WHERE x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '28428972647777557') LIMIT 20
    at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.getMappedQueries(QueryMapper.java:281)

Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: 'MyFirstModule.PremiumRequest_RequestPackage' is not a valid entity type., exception occurred on mapping the following query: SELECT x1MyFirstModule.RequestPackage.ID FROM MyFirstModule.RequestPackage AS x1MyFirstModule.RequestPackage INNER JOIN x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage AS j1myfirstmodule$premiumrequest_requestpackage WHERE x1MyFirstModule.RequestPackage/MyFirstModule.PremiumRequest_RequestPackage/MyFirstModule.PremiumRequest = '28428972647777557'
    at com.mendix.connectionbus.retrieve.query.mapping.QueryMapper.getMappedQueries(QueryMapper.java:281)

Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: 'MyFirstModule.PremiumRequest_RequestPackage' is not a valid entity type.
    at com.mendix.connectionbus.util.LegacyModel.$anonfun$getMetaObject$1(LegacyModel.scala:43)

 

 

answered
0

I show you part of the data model. It is not the simplest… 

You should open the image in a different panel to see it correctly...

answered
0

I read the following documentation:

https://docs.mendix.com/refguide/xpath-source

It states, that “If XPath is selected as the data source for a widget then the object or objects shown are retrieved directly from the database with a query. ”

Does this mean, that non committed objects cannot be retrieved by XPath? So I cannot use XPath on a newly created object in the context of a page, which is not committed yet?

answered