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%]']
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
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.