Hello everyone!
I created a flow that's kicked off by a checkbox that transfers various records someone owns to their supervisor, and then looks to see if the triggering record has any direct reports in Salesforce. It does this by looking at a custom field on each user's page that captures their immediate supervisor's ID, and if it matches the triggering record, that direct report's manager ID is updated to a new one from a 'replacement supervisor' field.
In all tests it works great and does exactly what I wanted.
But then I realized that whoever is selected as the replacement supervisor COULD BE one of the direct reports, and updating that specific user record would set themselves as their own immediate supervisor. Which obviously doesn't work.
I've been trying to figure out if I can do a decision element or a loop (I'm so confused by loops at the moment!) to make this work and I really need some help.
So I have a Get Records that looks up any user where the Immediate Supervisor equals the triggering record's user ID and I store all records.
And then I have an Update Records where the condition is Immediate Supervisor equals the triggering record's user ID, and then I update the Immediate Supervisor field on those specific records to the User ID for the person in the lookup field Replacement Supervisor for Team from the triggering record.
How can I isolate if there's a record where the Immediate Supervisor ID = Replacement Supervisor for Team ID, and then update that one specific record so that instead of the replacement supervisor that record's new supervisor is the triggering record's current supervisor?
I really hope all of that makes sense!
Including screenshots from the flow for the get and update records part.
Immediate Supervisor and Replacement Supervisor are both on the User object.
Immediate Supervisor is in use all the time in reports and on profiles and in other places. Replacement Supervisor is only going to be used when someone who has direct reports is being deactivated or will be moving out of the supervisory role and everyone who reports to them needs to be shifted to another supervisor.
I had originally intended for direct reports to just be reassigned to the immediate supervisor of the person being deactivated or being moved from the supervisory role, but that's not always the case. Sometimes someone new has already been hired for the role, or someone else in the company is moving into the position. Which is probably more information than you actually needed.
In your example hierarchy, the records being assigned has (or should have) no impact on direct reports. Immediate Supervisor listed will always get still open records moved to them to review and finalize or move to someone else as they see fit.
And anything owned by Steve should still be owned by Steve at the end of the process. They're still active and in their correct role. It should just be updating the immediate supervisor field to whoever is indicated in the Replacement Supervisor field.
Unless, of course, Steve is moving up to Mikey's role as the supervisor. Steve can't report to Steve, but if say there were other teammates on the same level as Steve, they should all be reporting to Steve. And Steve should default to reporting to Tabitha as the next level up supervisor - or in this case as the supervisor who is in the Immediate Supervisor role for Mikey when the flow runs.
I hope I didn't make this even more convoluted!
Tabitha