Any way to select one in one to many relationship via XPath?

1
In my domain model I have a 1 to many relationship between line manager and employee, which are both of the same entity type, Account. If I create a template grid with a list of Accounts, I can traverse the association tree and check whether the current user is the line manager of each employee, resulting in a list of people they supervise: [Administration.LineManager_Supervisees = '[%CurrentUser%]'] How would I go about creating an XPath which results in the current user's line manager? It seems to me I need something like the following pseudocode, which doesn't seem possible: [id = '[%CurrentUser%]'/Administration.LineManager_Supervisees/Administration.Account]   I need to use an XPath as I am using the PredefinedFilters widget to provide some powerful and user friendly search functions.
asked
2 answers
4

Hi Feargus,

Check out this article about retrieving data over self references: https://docs.mendix.com/howtogeneral/tips/querying-over-self-references.

 

There's a function called reversed() that should do what you need.

answered
3

Hi Feargus,

I think you need

reversed()

in your Xpath:

[Administration.LineManager_Supervisees[reversed ()] = '[%CurrentUser%]']

answered