+ Start a Discussion
SFDC developer999SFDC developer999 

how to filter report data by user who runs report

I have an object that stores salary of all employees: column employee name and column salary, there is no userId column in this object.
User object is the lookup object of this Salary object.

How can I build a report that show only salary of the employee who runs the report.

If employee A runs report, he can see only his salary, Employee B can see only his salary...
Thanks



 
kryzkryz
Hi,

Assuming that you are assigning the Employee Name to a Salary recod via lookup(Users), here's my solution. You need to create a formula in your Salary object with Text as a return type:
 
IF(Employee_Name.Id = $User.Id, "True", "False")

Employee_Name.Id​ -------> Id of the Employee within the Salary record
$User.Id ---> Id of the current logged in User

Save the formula. You can hide this from the page layout if you wanted.
 
Then create a report with a filter:

Your_Formula_Field__c equals True
SFDC developer999SFDC developer999
This is great Kryz , thanks so much.
Tom InwoodTom Inwood

Hey, I've tried using the solution above - but I get the following error when I try to use $User.Id

Error when encoding row-level formula: Field $user.id does not exist. Check spelling.

Any idea why I cannot access this variable?

Thanks! :)