function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Edward Scott 5Edward Scott 5 

trigger to change a field based on the viewer

I am new to writing apex code but I have successfully written a few triggers so any advice on this would be greatly appreciated.

I am creating a case process where when one of my sales rep's quota changes during the year our accounting department will create a case that will then be sent to the rep's manager and after they approve it sent to the rep to view the new quota. The only problem I can see with this process is a rep's quota is very sensitive information. So what I would like to do is one of two things. The first soultion that came to mind is write a trigger that will blank a field if the person viewing it isn't the rep that the change is for (I created a field named "Change For"). The second is creating a second field that is only visible to a few profiles that holds the reps quota and if the person viewing the case is the person that the change is for then it will copy the value from the quota field and if not its blank or 0.

I am not sure if either of these are possible or if there is a better way to do this. Again any advice is much appreciated.


Nayana KNayana K
I have never worked wih encripted fields. I am not much sure whether encripted fields suits in your scenario but you can just go through once.