Filtering data based on System.user and linked domain user

3
I am building an application for managing chip-cards online. A card has an owner (the person paying for it) and a holder (the person carrying it) which may or may not be the same person. I now want to create a form that lists all cards owned by the current user by default, and where an owner can search the cards he pays for, for example to list all cards carried by the same person. Searching for a specific holder is easily done, but restricting the search to only show cards that the current user pays for is a bit harder. An owner has a reference to a System.user, so it should be possible to do a search for all cards where the holder must match the search criteria the user specifies, and the owner must always be the owner linked to the current user. I just can't find how.
asked
2 answers
4

This depends on how you set your associations between the metaobjects. If card is the owner of the association card _ owner it is quite simple. You just create a form with a datagrid on cards and apply an Xpath on the datagrid. [card_owner = '[%current_user%]'] For more information on how to use Xpath see link

answered
2

I can think of two ways how you can do this.
Option 1:
Create a form with one datagrid with an xpath constraint: [Module.card_owner= '[%currentuser%]' or Module.card_holder= '[%currentuser%]']]
With at least one search field on the association card_owner/user/name one of the properties of an search field is 'Default value' if the searchfield applies to an user object you can select the token '[%current_user%]' here.
This way the first time you open your datagrid the user will only see an overview of his own cards and if he removes his name from the search field he will also see all the cards of which he is the holder

Option 2:
Create an entity: CardSearch which has an enumeration attribute and a reference to the user (this is tom make sure that you don't get a lot of empty useless objects), from the menu item, find the CardSearch object from the current user or create a new one.
The form must contain a dataview with 4 rows, on row one the enum here the user can select which cards he want to see (owner, holder or both).
On the second row show a grid with an xpath which has a constraint over the owner association
On the third row show a grid with an xpath which has a constraint over the holder association
On the fourth row show a grid with an xpath which has a constraint over both associations

When you apply conditional formatting to the rows it looks to you user as if the grid content changes.
If you use this second option make sure that the grid property show empty rows is applied, this gives a much cleaner look.

answered