1

Settings in Current environment :

  1. OWD settings for Activity = Private
  2. 'Grant Access using Hierarchies' set to checked - to allow everyone above the 'Assigned To' Task in the Role Hierarchy to view

Right now when say I create a task as a Sales person and assign it to a Sales Manager (some role higher than that of Sales Person) I can't find the task as the Sales person when I don't fill up the "Related To" field in Task

How do I configure it so that I can see ALL the task that I created as a Sales Person regardless of who I assigned it to?

1

On the Task object, the field whose label is "Assigned To" is actually the owner field (OwnerId). This means that when the creating user assigns the Task, they also transfer ownership and thereby lose visibility to the Task unless they obtain that visibility through some other route.

The role hierarchy cascades visibility up, so the Sales Manager would be able to see this Task prior to being assigned to it, insofar as they sit above the Salesperson. It doesn't cascade back down, though, and it sounds like you would not wish to create a sharing rule that would, for example, share all of the Tasks assigned to the Sales Manager to the roles under them. That wouldn't be granular enough.

Unfortunately, I think the only route here that will fulfill the requirement in full generality and with the level of granular visibility you're looking for is Apex-managed Manual Sharing. This would entail writing a trigger to add a sharing row to the Task's creator at the point when ownership is transferred.

The sharing row would have RowCause Manual, and UserOrGroupId equal to the creator of the Task. The trigger handler would have to run without sharing, or it'll throw an exception, because once ownership is transferred the original user doesn't have the right to add a sharing row.

You cannot use Apex Managed Sharing on standard objects, so what you'd be doing is using Apex to create manual share records. This comes with some notable drawbacks, including that the manual shares don't survive any further ownership transfers, so your code will need to be careful and defensive. Manual shares can also be removed by users who have permission to do so, like the Task owner.

There's an example of using Apex-managed manual sharing here in the Salesforce documentation, under "Creating User Managed Sharing Using Apex". Note the use of the RowCause Manual, which identifies manual sharing rows.

  • Yes 'Assigned To' API name is 'Owner'. There is still the 'Created by' API Name which is 'CreatedBy'. To be clear, I want the 'CreatedBy' to be able to see all the task he created regardless of who he/she assigns it to. Would i still require this complex apex sharing? – compski Nov 19 '18 at 4:11
  • Yes, that's exactly what I'm going for. The Created By field has no special meeting in the sharing architecture unless you build that. – David Reed Nov 19 '18 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.