2

Good morning!

Trying to use Apex or alternative methods to stamp a Role Hierarchy's senior levels into custom text fields based on the Record Owner's position in the Hierarchy upon status change. Scenario follows:

John is the CEO at the top of hierarchy. Jane and Julia are SVPs of Silo A and B respectfully. Adam and Brian are VPs under Jane, Chris and Davin are VPs under Julia. Each VP has 2 directors under them (Adam1,Adam2,Brian1,etc), and under those directors are employees.

If Kathy is under Director Davin1 and is the Record Owner when the status change occurs (Open -> Close), what code would be necessary to stamp her Director, VP and SVP into Custom Fields on that record?

Assuming this can't be done via workflow but open to alternatives. Thoughts?

4
  • I run into this same problem, which we need to be able to aggregate statistics at our 10 levels. Today, we export the data and process using SQL Server (not ideal). I would recommend loading a custom object with your hierarchy for each user (via trigger) and relate the two objects. From here, you should be able to create a custom report type and you can then use the realted hierarchy record to summarize your reporting.
    – James
    Commented May 12, 2015 at 13:15
  • Thanks for replying James. While your idea sounds viable, the goal (which I should have mentioned, apologies) is to snapshot the Hierarchy at that moment in time when the status changed. Your custom object sounds like it would be one record per user, thus it would reflect any changes to the Hierarchy across all previous status closings. Ex: Kathy closes an April Opp, status triggers Davin1,Davin,Julia to be stamped. Julia replaced with Joan. Kathy closes May Opp triggering Davin1,Davin,Joan stamp. What does April Opp say when re-opened? Am I misunderstanding your solution? Commented May 12, 2015 at 13:25
  • Ah, that makes sense and would change my recommend. Do you need to be able to report on it in salesforce, or capture it for auditing purposes similiar to field history tracking?
    – James
    Commented May 12, 2015 at 13:48
  • Yes, the Hierarchy senior level values would need to be reported on. They will be used mostly for determining commission paths when deals are closed. The idea is to use this functionality with the Orders > Contracts > Entitlements objects, but even a custom object implementation is fine. Commented May 12, 2015 at 13:53

1 Answer 1

0

You should be able to leverage a combination of flow and custom object. Further, this is much easier to manage/implement than writing custom triggers and classes.

  1. Create Custom Object ("Won Deal Commission Hierarchy") and make it a child of Opportunity
  2. Create a Flow which queries ownerId of current Opportunity and loop through hiearchy to obtain various levels desired and store in Flow Variables (may get tricky if you need to standardize the level in the hierarchy)
  3. Have Flow create a new Won Deal Commission Hierarchy record and assign values obtained from step 2, and relate to the current Opportunity.
  4. You may want to put logic to remove the old record in case the deal is re-won at a later date.
  5. Save Flow as "autolauched flow" -- make sure no screen items exist in flow
  6. Go to Setup> Process Builder and create a process that runs on "update" for Opportunity when isWon = TRUE and select your autolaunched Flow from step 3. Be sure to "activate"
2
  • Many thanks James, this is very appreciated. I will bounce this solution off my sandbox and report back if successful. Cheers! Commented May 12, 2015 at 14:53
  • Awesome, looking forward to hearing back. Best of luck!
    – James
    Commented May 12, 2015 at 14:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .