how to make xpath constraint dynamic in a page with data view

0
the xpath constraint below is working.  It is getting the recordsd that belong to username = ‘dan’ Instead of hard coding ‘dan’, I would like to use an xpath variable that returns the current logged in user               \
asked
4 answers
1

You created the right association, so you can put this in your xpath:

[Nutrition.NutritionTracker_Account = $currentuser]

It will retrieve all the records in nutritiontracker for the logged in user. 

You can check https://docs.mendix.com/refguide/modeling for help :) GL

answered
0

Hi Daniel,

First retrieve the first user account by retrieving on account entity, ID = $currentuser/ID. Then store that in a variable and use $account/name in your xpath constraint.

Edit: perhaps it's better practice to associate NutritionTracker with Account.

Goodluck

answered
0

Hi Ruud,

I am a bit new at Mendix.

Is there a mendix document that helps to build my domain model ha

 

Here is the nutritiontracker table 

All records inserted into it but belong to the account user id logged in.

The purpose is that each person will be able to track their daily food taken by category (breakfast,lunch,snack,dinner)

 

 

answered
0

hi,

 

here is the answer:

Since the nutritiontracker entity was storing the owner attribute (the user id that created the record)

I just had to the constraint like:

 

answered