Tito
Tito

Reputation: 804

Many-to-many relationship using 2 grids in the same form

I am new to AX, so it could be a simple question.

Imagine two tables Users and Groups in many-to-many relationship:

So, I created 3 tables in AX, to represent this relationship:

Now imagine I have a form with 2 grids.

Each grid has only one column not editable. One grid with the Users list (with the User table defined as DataSource) and another with the Group list (with the Group table defined as DataSource).

Everything is displaying fine, but I would like to have the behaviour that when selecting a Group just appears the Users it belongs, and them I can select the user.

How to do this last part ?

Upvotes: 1

Views: 1494

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

Showing users belonging to a group involves using an exists join on the GroupUser table.

It was not clear to me from your description, whether this was the case always or only when a group was selected.

Make a new form datasource using GroupUser with JoinMode set ExistsJoin and linked to the User table.

If only filtered when a group is selected, make the GroupUser datasource disabled:

user_ds.query().dataSourceTable(tableNum(GroupUser)).enabled(<group is selected>);

Upvotes: 3

Related Questions