Create Custom XPATH System Variable

0
  Hi,   Is there a way to create a new custom system variable? Like the default one provided by Mendix. //Sales.User[id = '[%UserRole_Administrator%]']]   I want to do something like this.  The new variable will be calculated at authentication stage. And that variable I will be using to filter what data a user should be viewing. //Sales.User[name = '[%CurrentUser_Custom_Variable%]']]      
asked
3 answers
1

Hi Jonard,

I don’t think Mendix allows to create custom variable, however, your problem can be easily solved by having a non-persistent entity with one or more attributes. Just assign the value to one of the attributes and it could be accessed during the user session. Make sure to allow only read access to the users.

Regards,

Shekhar

answered
0

Hi Jonard, did you manage to fix the problem in the end? I have a similar issue and I want to access information about the current user in an XPath for a data grid. I tried Shekhar’s solution however it didn’t work the XPath was not compatible with non-persistable entities

answered
0
  1. Its not possible
  2. Alternate:
    1. Given you want to customize the values per user and want to use it in XPATH
    2. Create an Persistent entity UserHelper with attributes that you need per user
    3. Associate that with System.Session 1-1 with UserHelper. Set the association to: On delete of System.Session, delete your UserHelper object as well. With this, you can scope this per session. If you dont set onDelete, then lot of objects will be created.
    4. When logged in, you are redirecting the user to some home page, via naviation profile. There create a microflow, create user helper and set proper values. Set the association to Current Session
    5. $currentSession is always available in almost all places to be used. There you can navigate to your UserHelper and required attribute to filter your data. 

 

Word of Caution: DO NOT tag of entities with session, because it will lead to performance issues as well. 

answered