Showing only logged in user's records in a filtered report

Showing only logged in user's records in a filtered report

Requirement  

Display only the relevant records for the logged in user, based on the customer email, to ensure the security and privacy of the data from other users in the application.

Use Case  

An order management application has the Order form that holds the product details bought by a customer. In this application, a customer can search through his orders. It would become difficult for the administrators and the users if every user was able to view all the records. This is why data needs to be filtered, so that only relevant records are displayed to the user who is logged-in.

See how it works

Steps to follow  

1. Create the form with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Orders
Orders
 
Email
Customer Email
Customer_Email
Currency
Total Amount
Total_Amount
Subform
  • Single Line
  • Numbers
  • Currency
Order Details
  • Product Name
  • Quantity
  • Sub-Total
Order_Details
  • Product_Name
  • Quantity
  • Sub_Total

2. Assign the initial value as zoho.loginuserid to the Customer Email field.
 
3. Create a workflow to execute on the load of the Orders form to disable the Customer Email field.
 
4. Click Add New Action and add the below code to the Deluge editor:
  1. disable Customer_Email;
This will ensure that the logged-in user's email is added initially and the user cannot update the value.
 
5. Create a report named My Orders from the Order form. This will hold only the orders of the current logged-in user.

6. Open the Report Properties of the My Orders report. Click Add Filter and, in the ensuing dropdown, select the field as Customer Email, operator as equals, and the value as zoho.loginuserid.

See how it works  

Points to note  
  • Although this method is quite effective in separating irrelevant data for the customers, one can create profiles and assign them dynamically to users. Read more about profiles in the link.
  • Duplicate the All Orders report to create the My Orders report, based on the criteria as follows: