Creator reports restrict access by user ids
Here is what Im trying to do. I want to show records of my report only to selected users, in my case I have many Hotels
and I want users to see records only for their own Hotel. Here is how Im doing this:
Im creating certain groups of users by creating a form User_IDs which holds "hotel_id" and an Email (which is zoho.loginuserid) , so each logged in user belongs to a "hotel_id".
In my Hotel_Details form I have a lookup field hotel_id, so I want to show records only if zoho.loginuserid in form User_IDs user's "belongs" to this hotel_id.
Here is the part of Hotel_Details_Report from report definition, in code (this doesnt work):
list Hotel_Details_Report
{
displayname = "Hotel Details Report"
show all rows from Hotel_Details [hotel_id_lookup == User_IDs[Email == zoho.loginuserid].hotel_id_lookup]
(
...
the above code results to an empty report, but when I explicitly write the ID of the lookup it works, in code:
list Hotel_Details_Report
{
displayname = "Hotel Details Report"
show all rows from Hotel_Details [hotel_id_lookup == 1838015000000070003]
(
I cant understand why the first one doesnt work and the second works, theoriticaly "User_IDs[Email == zoho.loginuserid].hotel_id_lookup" equals "1838015000000070003".
I see the lookup ID by doing
alert User_IDs[Email == zoho.loginuserid].hotel_id_lookup;
My guess is that this code: "User_IDs[Email == zoho.loginuserid].hotel_id_lookup" doesn't run as expected in report definition.
So maybe you can tell me what am I doing wrong or if there is an easier way to accomplice this control over the reports.
Thanks in advance.