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
Mayank.msMayank.ms 

how to find opportunity owner in after update trigger

I need to get Opportunity Owner name In the  opp trigger. Can anyone help on this ?

here is my trigger code :

 

trigger PortalCallout on Opportunity (after insert,after update) {

    if(Trigger.IsInsert){
       for (Opportunity o : Trigger.new) {
           // make the asynchronous web service callout
           HttpResponse r= new Httpresponse();
           SendDataToPortal s = new SendDataToPortal();
           if(o.Subscriber_ID__c!=null && o.Client_ID__c!=null ){
               r = s.sendNotification(o.Subscriber_ID__c, o.Id, o.AccountId,o.Client_ID__c,'','','','','','','',o.Name,'','','','insert');
           } 
           //system.debug('r');
      }
    }
    if(Trigger.IsUpdate){
       for (Opportunity o : Trigger.new) {
                    // make the asynchronous web service callout
        HttpResponse r= new Httpresponse();
        SendDataToPortal s = new SendDataToPortal();
        String cdate = NULL;
        String isOppNameUpdated = 'false';
        String isCancelFldUpdated = 'false';
        String isOtherFldUpdated = 'false';
        //system.debug('r');
    
        /******************************** REPLACE SALESFORCE ADMIN UserID ON PRODUCTION ***********************************/
           if(userinfo.getUserId()!='005160000064dkRAAQ' &&  o.Subscriber_ID__c!=null && Trigger.OldMap.get(o.Id).Name!= o.Name){
               
               isOppNameUpdated = 'true';
           }
           
           if(userinfo.getUserId()!='005160000064dkRAAQ' &&  o.Subscriber_ID__c!=null && (Trigger.OldMap.get(o.Id).Cancellation_Reason__c!= o.Cancellation_Reason__c || Trigger.OldMap.get(o.Id).Cancellation_Date__c!=o.Cancellation_Date__c || Trigger.OldMap.get(o.Id).Cancellation_Feedback__c!=o.Cancellation_Feedback__c)){
               
               isCancelFldUpdated = 'true';
               cdate = string.valueof(o.Cancellation_Date__c);
           }
    
           if(userinfo.getUserId()!='005160000064dkRAAQ' && o.Subscriber_ID__c!=null && (Trigger.OldMap.get(o.Id).Accounting_Platform__c!= o.Accounting_Platform__c || Trigger.OldMap.get(o.Id).Order_Volume__c!= o.Order_Volume__c || Trigger.OldMap.get(o.Id).promo_code__c!= o.promo_code__c)) {
               isOtherFldUpdated='true';
               
           }
           if(isOppNameUpdated=='true' || isCancelFldUpdated=='true' || isOtherFldUpdated=='true'){
               r = s.sendNotification(o.Subscriber_ID__c, o.Id, o.AccountId,o.Client_ID__c, o.Cancellation_Reason__c,o.Order_Volume__c,o.Accounting_Platform__c,cdate,o.promo_code__c,o.Cancellation_Feedback__c,o.Susbcription_Status__c,o.Name,isOppNameUpdated,isCancelFldUpdated,isOtherFldUpdated,'update'); 
           }
    
        system.debug('r');
    
    }
  }

}

AbhinavAbhinav (Salesforce Developers) 
Hi Mayank,

Is owner not coming  while checking   Trigger.old[0].OwnerID??
 
Mayank.msMayank.ms
@abhinav ..  I have got the solution for It. Thanks Abhinav for your concern on this.