XPath retrieve of objects depending on CurrentUsers settings

0
Hi all,   The situation: I'm doing an XPath retrieve on an entity 'Reservation'. Each Reservation is linked to a location (* - 1). Also, most users are via their account associated to a location (* accounts to 1 location). Some users have a location associated to their account, but users don't. I'm using an XPath retrieve for a datacounter, so I cannot have a microflow as datasource. What I'm trying to accomplish: I want to an XPath retrieve that retrieves the reservations of a location, where the location of the reservation is the same location that is linked to the current user's account. However, if the current user does not have a location linked to its account, I want to retrieve all the reservations. (There are some other XPath constraints that I use, but those are irrelevant).   Does anybody know how this can be done in an XPath? I can't check whether the association is empty from the CurrentUser, because I can't start with currentuser in an XPath. I tried the following, but that doesn't give the desired result, because I can't check whether the location of a reservation matches the location of an account if the association between location and the user's account is empty. [(Reservations.Reservation_Location/MasterData.Location/Administration.Account_PreferedLocation = '[%CurrentUser%]' and Reservations.Reservation_Location/MasterData.Location/Administration.Account_PreferedLocation/Administration.Account) or not(Reservations.Reservation_Location/MasterData.Location/Administration.Account_PreferedLocation/Administration.Account)]   Any help would be appreciated!
asked
1 answers
1

Hello Mark,

I'm afraid you cannot perform checks in XPath - or any form of if statements.

I recommend using a non-persistable entity that you can populate by microflow which evaluates whether you need to show all reservations or just the user's reservations and then stores that in a boolean. You can then use conditional visibility to display either a grid with all reservations or one with the user's reservations. 

The other way you can do it is with role visibility or role-based entity access if your use-case is something like "User must see their bookings while managers must see all bookings" - this would be better but it doesn't sound like it matches your use-case.

Hope this helps

answered