You need to sign in to do that
Don't have an account?
chvl narayana
I can we change owner if Owner is inActive
Hii all
Hope you are doing good
I have a two users. user1 and User2
User2 is manager to User1.
User1 have created some records. If user1 isActive is false,
Manager will be the record owner.
I Write code like this
trigger RecordOwnerChangeEx on User (after update) {
list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
// list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
list<account> ac=new list<account>();
for(User uu:u){
if(uu.IsActive == false && uu.ManagerId != null){
for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
a.ownerId = uu.ManagerId;
ac.add(a);
}
}
}
update ac;
}
Hope you are doing good
I have a two users. user1 and User2
User2 is manager to User1.
User1 have created some records. If user1 isActive is false,
Manager will be the record owner.
I Write code like this
trigger RecordOwnerChangeEx on User (after update) {
list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
// list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
list<account> ac=new list<account>();
for(User uu:u){
if(uu.IsActive == false && uu.ManagerId != null){
for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
a.ownerId = uu.ManagerId;
ac.add(a);
}
}
}
update ac;
}
Hi Narayana,
This can be done using Process Builder and Flows. The idea would be this:
1. Create a Process on the User object.
2. Fire it when a user record is marked inactive.
3, Launch a Flow.
4. Pass this user's ID into a Flow variable.
5. Within the Flow, find all accounts that have the Account Owner ID = Passed in User ID
6. Mass Reassign the found accounts to deactivated user's manager.
For the flow part of the implementation, you can take cues from the following link(Reassign Accounts):
https://resources.docs.salesforce.com/sfdc/pdf/workbook_flow.pdf
I would recommend to use Mass Transfer for transferring Account from user1 to user2.
Set Up>Data Management> Mass Transfer Records>Transfer Accounts. Hope this helps!
Best Regards,
Sourav.