referencing %System.User% from Xpath

0
I've designed a domain model for a multi-tenant app. Each [unique] user name (in a TenantUser table) is associated with an org (a Tenant table). I have a table of items for all orgs. I want to use Xpath to constrain the rows to those associated with the current user's org. The Xpath constraint begins by referencing the Name attribute in the Tenant table associated with each Item. I need to compare each name with the Name in the Tenant table that matches the current user's name, as follows: [MyFirstModule.Item_Tenant/MultiTenantAdministration.Tenant/Name = '[%CurrentUser%]'.Name] but the right side of this expression is rejected by the modeler! Any suggestions appreciated.  
asked
5 answers
0

You shouldn't use the System.User unless you are storing the "Created By" and constraining by ownership.  I believe you want to constrain using the Account entity, therefore you need to make an association....

You could create an association (1 to 1) from MultiTenantAdministration.Tenant to Administration.Account  (Or consider a * to 1 if you have multiple users for each Tenant that can see the shared Tenant data...)

You would edit the user profile page to have a drop down selector for Tenant that they belong to.

Then update your Xpath constraing on the Tenant entity by using the "Path to user" button. Drill down the association until you hit the account.

 

 

answered
0

Does a TenantUser inherit from System.User? If so, why can you just use the association without the /name part of it? If not, why doesn't the TenantUser inherit? You probably also want [%CurrentUser%].

answered
0

I've tried a variety of approaches and am blocked on an inability to filter a list by an attribute being equal to CurrentUser.Name

 

Confident this is a use-case others have experienced and solved.

 

To boil this down:

if you have an entity, call it Foo, it has an attribute 'Bar'

you need to point a DataGrid or DataView to Foo with the constraint that Foo/Bar = CurrentUser/Name

 

My actual situation is more complex than this but let's start here... If this cannot be accomplished with DataSource XPath then perhaps with a Microflow? Thanks

 

answered
0

How does this not work..?

[MyFirstModule.Item_Tenant/MultiTenantAdministration.Tenant/MultiTenantAdministration.TenantUser_Tenant = '[%CurrentUser%]']

 

It gives you all the items belonging to the TenantUsers organization (tenant..)

Basically, the token '[%CurrentUser%]' is replaced by an ID when executing the comparison. TenantUser_Tenant also resolves to an ID, the be more precise it resolves to the ID of the TenantUser-end of the association between Tenant and TenantUser. TenantUser inherits from System.User, so those two will be the same..

 

answered
0

solution is here: https://forum.mendix.com/link/questions/91629

answered