• Upasna Lal
  • NEWBIE
  • 40 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

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;

Tried with this but not working. 
is it possible to create new field of  multipicklist value in Outlook and do a sync with salesforce multipicklist value
outlook salesforce integartion :+Event Type field I want to display while logging the Event . Is log event customizable .
is it possible to create new field of  multipicklist value in Outlook and do a sync with salesforce multipicklist value
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

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;

Tried with this but not working.