How to restrict report information to logged in user only
If you are trying to set up a report that is safe for users to use without revealing information they shouldn't have, there are a variety of ways:
- You can use Exo Config to remove the report(s) from the employee's Menus.
- You can customise a different version for the user, and set them a custom clarity folder with their own reports.
- Or you can restrict the report information by either:
- Setting up a Runtime Parameter for the report.
- Adding a restriction to the data pipelines.
To restrict access to a user in the data pipeline
Option 1: Add a parameter to the BeforeOpenDataPipelines event in Clarity.
This method makes use of the Clarity function "LoggedInStaffNo" which reports back the user Clarity is running as.
In the Calc tab of Clarity, you can change the BeforeOpenDataPipelines event
Add code like the following, (Note, this is written for a report where the Sales Person (SALESNO) is being restricted to the currently logged in user.
Procedure BeforeOpenDataPipelines;
begin
Report.CreateAutoSearchCriteria('MASTER', 'SALESNO', soequal, IntToStr(LoggedInStaffNo)), True);
end;
Option 2: Edit the Runtime Parameters to add a Parameter with 1 option.
This method makes use of a the SQL level FN_GET_STAFF_NO to set up a Report Parameter with only the logged-in user as an option.
The code for the Default SQL & SOurce SQL is set to:
select dbo.FN_GET_STAFF_NO() AS SALESNO
Source SQL is set to:
select NAME, STAFFNO AS SALESNO
FROM STAFF WHERE STAFFNO=dbo.FN_GET_STAFF_NO()
Depending on the exact table/reports you want to restrict, you will need to change the "AS" part of the above Source SQL, so that the column name is the same as the Key Field, (In this example, I rename the Staffno field to Salesno so it matches to DR_TRANS.SALESNO
Using this method, the report user could untick the Enabled box, which means this restriction can be easily turned off (If the user needs to be able to run the report either for everyone sometimes).
Option 3: Use the Search tab of the Data Pipeline to call dbo.FN_GET_STAFF_NO() as part of the where clause
![](../__attachments/86769786/image2022-11-2%2011:22:58.png?inst-v=0a9f74fc-52bb-4417-9d92-31d0022bf099)
If you need more help with this topic, contact your MYOB Exo Business partner. If MYOB support you directly, email businesssupport@myob.com.