xpath constraint on data view based on attribute logged in user

0
Hi, I’m trying to create an expense overview for two user types where the consultant inputs an expense and an account manager only sees the expense notes associated to his consultant. I set it up so that the consultant has to specify the email of the account manager when submitting an expense. I want to use this email in an xpath to only show show expense notes which match the email of the account manager logged in. How am I able to retrieve the email of the current user logged in and compare this in an xpath with an attribute? Best I could come up with was: [EmailAccountManager = '[%CurrentUser]'] But this doesn’t retrieve the email itself to see if it matches. Thanks    
asked
11 answers
1

The String error is because there is a percentage sign missing in the currentuser token. Did not see it. It needs to look like this:

 

[MainModule.ExpenseNote_ApplicationUser/MainModule.ApplicationUser/MainModule.ApplicationUser_Account = '[%CurrentUser%]']

 

answered
1

Unfortunately, that is not possible. You can’t access attributes of memory objects in page xpaths. In a microflow you could do that. But a microflow as datasource is different from xpath.

Is it possible to search and associate an Application User when creating the expans note? If the association is set, you could use it in your xpath like this:

[ModuleName.ExpanseNote_ApplicationUser = '[%CurrentUser]']

 

answered
1

How would I make it possible to search and associate an application user when creating the expense. At the moment I only ask for Email and wanted to use that to make a match. I can add a list of all users with that Type of user role. But how would I make it selectable and save it to that specific expense so I can retrieve it to show it for that user in a data view?

answered
1

You could us a reference selector to create a dropdown or select page in which the user can select the user. If the user is not supposed to see the ApplicationUsers that are in the database, you can still execute a microflow to save the expanse. In this microflow you can retrieve the ApplicationUser from the database. Retrieve by database. Only retrieve the first object. Use the following xpath:
 

[Email = $ExpanseNote/Email]

If you find something use the change object action on the ExpanseNote and set the association to the ApplicationUser. Then commit it to database. Now your association is set and can be used in the xpath.

answered
1

I now have the reference selector which only let’s you pick a user with the user role of AccountManager to associate it to an expense.

I’m still stuck on the part where I can use xpath on the data view of the account manager to only show expenses where he/she is selected on.

At the moment I have this but it doesn’t seem the correct syntax:

I note that it also expects a variable in your example xpath. I do not store the value in a variable anywhere as I can allow users to see the applicationusers in the database.

 

answered
1

Once the association is set, you don’t need the email compare anylonger. You can directly compare the association to the current User. Like this:

[ModuleName.ExpanseNote_ApplicationUser = '[%CurrentUser]']

 

answered
1

When I use that xpath, the accountmanager view stays empty.

This is the attribute path of my reference selector which i’m using: 

MainModule.ExpenseNote_ApplicationUser/MainModule.ApplicationUser/MainModule.ApplicationUser.Email

Email is an attribute on the “ApplicationUser” entity. ApplicationUser has an association with ExpenseNote named “ExpenseNote_ApplicationUser”.

The xpath constraint i was using in the data view of the account manager was: 

[MainModule.ExpenseNote_ApplicationUser = '[%CurrentUser]']

What am I doing wrong here? 

answered
1

I’m sorry, it was my fault. The ApplicationUser is not a user. For whatever reason, I was under the impression that it is a specialization of Account or user.
Is your ApplicationUser associated with the account/user? If so, you need to use this association.

[ModuleName.ExpanseNote_ApplicationUser/ModuleName.ApplicationUser/ApplicationUser_Account = '[%CurrentUser]']

It must be something like this. The module name and the association name may be different. I don’t see them in your screenshot.

Sorry again.

answered
1

Ah yes indeed, I linked ApplicationUser to Account so that the accounts are stored in the admin module. I tried changing the xpath to 

[MainModule.ExpenseNote_ApplicationUser/MainModule.ApplicationUser/MainModule.ApplicationUser_Account/Administration.Account = '[%CurrentUser]']

But this returns the error that the '[%CurrentUser]'] is not a valid boolean value

answered
1

You should remove the object part in the xpath and directly compare the association. Like this:
 

[MainModule.ExpenseNote_ApplicationUser/MainModule.ApplicationUser/MainModule.ApplicationUser_Account = '[%CurrentUser]']

 

answered
0

That is what I tried first, but this returned the error “incompatible expression types: Administration.Account,String” That’s why I added the Administration.Account part to the xpath but also without success. 

Could the issue have to do with the fact that the reference selector attribute path in my expense note is: 

MainModule.ExpenseNote_ApplicationUser/MainModule.ApplicationUser/MainModule.ApplicationUser.Email

And I am only looking for '[%CurrentUser]'] in the xpath of the data view for account managers?

answered