Reference Set xPath constraint regarding attribute in dataview

1
Hello Mendix Community, I am having trouble to filter the selectable objects of a reference set inside a dataview. I have a "Flight" object with a 'Destination' attribute (enum), additionally I do have "Parcels" with each having a 'Destination' too (same enumeration). Now I want to filter the selectable parcel objects to only allow adding parcels that have the same destination as the flight. Unfortunately I am not able to get the current flight object in the xPath. I read that '[%CurrentObject%]' refers to the id of the object the reference set is placed in. So that would be my flight - but how can I access it? I tried [Module.Flight[id='[%CurrentObject%]']/Destination = Destination] which doesn't work . Module.Flight is not available - I can only access the relations of Parcel. But [CargoSystem.Parcel_Flight/CargoSystem.Flight[id='[%CurrentObject%]']/Destination = Destination] doesn't work neither, I think because the association from Parcel to flight is not given yet. How can I solve this?
asked
4 answers
1

If you make your destination an entity with associations to both the flight and the cargo, then it should look something like this:

[CargoSystem.Parcel_Destination/CargoSystem.Destination/CargoSystem.Flight_Destination = '[%CurrentObject%]']

answered
0

Take a look at the contrained by function. I suggest playing with that option.

Regards,

Ronald

answered
0

I tried as David suggested, made a association between Destination and Flight as well as Parcel. I could then produce this exact xPath without giving errors in the Modeler.

[CargoSystem.Parcel_Destination/CargoSystem.Destination/CargoSystem.Flight_Destination = '[%CurrentObject%]']

But when I try to add a parcel to the flight, I can not even see the list of parcels. I get the same error as I did before

com.mendix.core.CoreRuntimeException: Exception occurred in action '{"amount":20,"sort":[{"direction":{},"memberName":"ParcelID"}],"formName":"CargoSystem.Parcel_Select","returnsCount":true,"offset":0,"type":"RetrieveXPathSchemaRawAction","xpath":"//CargoSystem.Parcel[CargoSystem.Parcel_Destination/CargoSystem.Destination/CargoSystem.Flight_Destination = '3659174697238529']"}', all database changes executed by this action were rolled back
at com.mendix.core.actionmanagement.CoreAction.c(SourceFile:515)
Caused by: l: An exception has occurred for the following request(s): 
fw (depth = -1, amount = 20): //CargoSystem.Parcel[CargoSystem.Parcel_Destination/CargoSystem.Destination/CargoSystem.Flight_Destination = '3659174697238529']
at x.a(SourceFile:49)
Caused by: l: Exception occurred while retrieving data. (SQL State: 42581, Error Code: -5581) Detail Message: org.hsqldb.HsqlException: unexpected token: ) : line: 17
at H.a(SourceFile:1398)
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: ) : line: 17
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)

The unexpected token : ) : line: 17 was thrown before. Since it is a sqlException I guess that something in the xPath is going wrong? I am sure my flight has a destination (I added it while creating the object via a reference selector, the same counts for the parcels).

answered
0

This is unfortunately still not working. No one any advice?

answered