Making an entity unique to a specific user (For the stock keeping of product for multiple users)

0
  Using the simple domain model showed below what do I need to do to make sure that when user 1 enters a product to his stock user 2 won’t see the exact same product in his stock? I'm sure this should be a verily easy thing to accomplish using Mendix. Just to clarify this is what currently happens: It currently does not matter if I login using my first user or second user, they will see the exact same thing.   Thank you for reading my first question on the Mendix forum, I hope someone can help me. Sincerely, Ivo
asked
3 answers
3

Ronald gives a very good answer. I just wanted to add that inside XPath constraint on a page etc, where you don't have accses to variables you can use the token '[%CurrentUser%]' to reference the currently loged-in user.

-Andrej

answered
2

You should set an XPath to make sure that a customer can only sees its own stock. I assume that users and customers are related somehow. It's not clear to me what the entity source is of the datagrid, but if it is Product then your XPath should be something like [Product.VoorraadLeverancier_Product/customer_stock_customer/customerID = $CurrentUser/ID]. It all depens a bit on the relation between Mendix users and customer.

It might be more efficient to create an extra reference between customer and products so you can simplify the retrieval of all products from a certain customer.

Regards,

Ronald

answered
0

Thanks for the reactions, after configuring the security level too Production it was as easy as filling in [System.owner='[%CurrentUser%]'] for the Xpath constraint.

 

 

answered