XPath constrain data grid based on attribute logged in user

Hello, I have this datagrid which is already filtered by XPath as datasource based on some attribute values within my domain model. I would like to further filter this datagrid based on an attribute which is part of MainModule.Account_ApplicationUser (ApplicationUser being my custom user entity linked to administration_Account)   So essentially I want the datagrid to be filtered based on an attribute of the logged in user. Is this possible through XPath?   Thanks
2 answers

You should wrap this datagrid in a Data view. 
This data view should have as datasource type a microflow.

In this microflow (meant to provide a record/object to the page) you must retrieve the current account then set this object retrieven as return value of the microflow (you can right click on the retrieve activity and select Set $retrievenObjAccount as return value…)

Once you have the record passed to the page you will be able to use the record as a parameter inside the datagrid xpath.

Hope this helps.


Assuming you have a domain model like this. Certainly with different Entity names and more and different attributes. But the structure with Associations must be like this. otherwise it won't work.

Given this domain model you could have a datagrid with datasource XPath and entity SomeDataEntity. And the following XPath:

[MyFirstModule.SomeDataEntity_ApplicationUser/MyFirstModule.ApplicationUser/MyFirstModule.ApplicationUser_Account = '[%CurrentUser%]']

Where you navigate over the path from your data entity to the Account entity in the Administration module and compare it '[%CurrentUser%]' which contains the ID of the current logged in user.

No need for a dataview with microflow datasource to catch the current user. Although this works, its overhead and will degrade your performance.


//EDIT/// Extend answer on input Eson in comments

In the case you want to filter on the company of the application user. and the company of the user must be the company of the DataEntity.

Don't store the company info in separated attributes, but normalize your data and Create a entity company and instead of when creating a new applicationUser with string value of the company, select/assign the new AppUser to the company object. Do the same with each new DataObject

And then you can use this XPath constraint:

[MyFirstModule.SomeDataEntity_Company/MyFirstModule.Company/MyFirstModule.ApplicationUser_Company/MyFirstModule.ApplicationUser/MyFirstModule.ApplicationUser_Account = '[%CurrentUser%]']