0

I am currently learning Salesforce. And I`ve got the task on courses about apex managed sharing rules. I need to use 3 standard objects - Account, Contact, User and 3 custom - Terr(as a territory), TeterritoryrrUser, Reference - junction objects in many-to-many relations. So I need to create a hierarchy of fields - country, region, city in Terr object in such a way, that User has access to specific territory and accounts, contacts on it. For example, if he has access to some region, he has access to all accounts in this region, including cities of this region. So I have tried to write some triggers for Account and User sharing rules, but I have got confused. I would be glad if someone gave me a hint, how to implement such a system.Diagram

  • That assignment is still not clear. How region is defined in terms of territory, for example, in set of cities?I see a solution as trigger on TerritoryUser and Territory to insert/update/delete shares on related(child) account, together with trigger on account, so every time if TerritoryUser is changed -> update sharing for accounts in related Territories, and every time when Territory is updated -- update sharings for child account, and on Account -- every time when account is updated -- update sharings to it based on territory. Trigger framework is advised :) – kurunve Mar 1 '17 at 8:14
  • Yes, a region is defined as a set of cities. I am not sure should I create trigger on User or on TerrUser? Many-to-many relations are quite confusing. Thank you very much for your advice :) – Cassie Mar 1 '17 at 9:17
  • 1
    I think territory user, cause with every update of territory user record, sharing should be updated for parent user. I dont see a scenario from requirements, when sharing should be changed according to the update on user itself – kurunve Mar 1 '17 at 9:20
  • Ok. I`m very grateful for your help! – Cassie Mar 1 '17 at 9:21

Your Answer

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

Browse other questions tagged or ask your own question.