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
dmasondmason 

Reassign records based on criteria

Hey All 

 

hope is well, i need some advice / pointers

 

I understand that with the new 14 release we can create triggers on the user object (not sure if this is the case)

 

Aim - In this example https://www.youtube.com/watch?v=QrtVN8vZGJU you can see that “Jim Smith” is going through the  de-activation process . What i want to do, is when you press save, an apex trigger  is triggered and automatically re-assigns “Jim Smith” Leads into this appropriate manager

 

Looking around, It shouldn't be an issue to grab the users's id, and the manager id and change ownership of those leads to the new user, but i may be mistaken and i need some help.

 

The Main issues that potentally could stop this from working is 

 

1.  If there isn't a manager listed you could not assign.

2.  If the manager is also inactive you will not be able to assign the leads (you can only assign records to active users).

3.  If any of the leads have not been edited by the current user and there is validation on the lead that hasn't been completed then the lead will not get reassigned.

Rahul_sgRahul_sg
User triggers were available before winter 14. They are allowing WF rules on the User from winter 14. (WF rule will not solve your requirement....you need to write a trigger on USer)

Below are answers to your 3 questions:
1) in this case you can assign that lead to a pre identified admin user or a queue.
2) same as 1....assign to a queue
3) here you have to code around your validation rule. or add an exception in your validation rule
Boom B OpFocusBoom B OpFocus

I agree with all Rahul's 3 answers, but I want to add a tip for #3 to add an exception in all the lead validation rules with AND Owner:User.IsActive = true. So the trigger can reassign the leads from the inactive user without errors from the lead validation rules.