Xpath database retrieve where=$currentUser

0
On a microflow I have a database retrieval that works when the Xpath constraint is blank and the first data item is displayed on my form. I get nothing returned when Xpath contraint is [LastName = '[$currentUser]'] . Any ideas? Is the syntext wrong? - I was expecting it to work like a simple SQL where clause - can any one help - I am using the builtin signon facility to logon and expecting the $currentuser to be populated.
asked
6 answers
1

First retrieve the User object associated to currentUser by using the xpath in David's answer. Then retrieve the Customer object by using the following xpath: [LastName = $User/Name].

answered
1

OK, I'm assuming that you are playing with the Pizza Mario project. In that project the Customer entity has no association to the Administration/Account object, so you cannot filter on the Account (login user).

You can use the system maintained association to the Owner (the person who created the record) by adding the X-Path constraint to the Customer Overview:

[System.owner = '[%CurrentUser%]']

But, to make this work you need to make a few changes from the default for this project. You need to disable anonymous access under Project security, and force people to log in (Security Level = Production or Prototype). This will probably entail you setting correct access permissions on your entities and microflows. After this change, all users will need to log in, and then the Customer will be associated with the user who created it. You can then filter using the XPath.

If you allow anonymous access, you do not know who the user is and no such filtering is possible.

In a normal Project, you would probably not rely on the system maintained link to the Owner, but would create an association between the Customer and Account entities. Then set this though a microflow or allow it to be set in the form, and use that association as the XPath filter

answered
1

Hi David, thanks for your help, this is now working as I expect it to. In fact your 1st reply and Jaap's help cracked it for me.

You have also provided the solution to me next mission, which is to show records which the user have created and not any other peoples records. However, I did notice that when creating the Entity (in version 4.2.2) I may have to check-box "Store Owner". I believe in previous versions this check box was set as a default. I am assuming that with this box checked only then I can use the X-path

[System.owner = '[%CurrentUser%]']

please correct me if I am wrong.

answered
0

Try [id = '[$currentUser]'] - sorry, that should be

[id = '[%CurrentUser%]']

Trying to match the current user ID to a Lastname string will not work. This assumes that what you are retreiving is a specialization of the User/Account entity. If it is not, you need to choose the association between the entity and your account object to compare to [%CurrentUser%]

answered
0

Hi, that did not work - I m trying to retreive a distinct customer row on the Mario Pizza project where the Customer's LASTNAME is equal to the signon user id.

answered
0

Try this one its works fine to get the user name in the login page dynamically [System.owner='[%CurrentUser%]']

answered