Self-referential selection page with two data grid constraints

3
Hi, I have a domain model with a single Agent entity. There is one self-referential association called Manager on this entity. I’d like to have a page that allows the selection of this association from the association child (e.g. you should be able to select the Manager Agent from the Agent’s detail page). For simplicity’s sake, the page should open to a data grid, which contains a search bar. There are two constraints of the data within the data grid: The data grid should not populate with the Agent object that’s already associated to the current agent via the Manager association (agents cannot select the same manager they already have). The data grid should also not populate with the current Agent (Agent’s cannot select themselves as managers).   I’ve attempted to build a feature like this using both reference selectors and a custom button but can’t get both constraints of the data grid to work. How would I implement a feature like this?   Edit: I replaced the word owner with child.   Thanks,
asked
3 answers
3

Xpath for data grid that you use to choose the manager might looks something like this. This datagrid will need to be embeded in the agent data view.

[id != '[%CurrentObject%]']

[agent_manager != '[%CurrentObject%]']

answered
3

Jon answer is on point. I would just like to point out that the query

[agent_manager != '[%CurrentObject%]']

will filter out all agents whose manager is the current object but also all agents who do not have a manager. To only filter out the agents whose manager is not the current object use

[not(agent_manager = '[%CurrentObject%]')]

Hope this helps,

Andrej

answered
0

Sorry, I contradicted myself when stating the requirements which caused some confusion! The requirement was to be able to select the manager from the agent’s page, not the subordinate agent from the manager’s page. So I should have said we need to select the Manager association from the child object’s page. I edited my original question to reflect this.

Jon and Andrej’s answers are still useful in understanding self referential associations.

The Xpath I was looking for is

[id != '[%CurrentObject%]']
[not(Manager[reversed()] = '[%CurrentObject%]')]

, which should be placed in the context of the subordinate agent’s data view. This prevents the selection of the current agent and also prevents the selection of the same Manager that’s in the database for this agent.

This isn’t very robust though, because if the agent selects a new manager without saving, the Xpath will still filter out the most previously committed Manager.

 

 

answered