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
Burak Yurttas 7Burak Yurttas 7 

Apex Trigger and Pardot Issue

Hi Everyone,

My company is using Sales Force and Pardot integration. We have the connector setup. According to Pardot, in sync between Pardot and Sales Force, Sales Force wins. If owner of the lead is James in Sales Force It should be James in Pardot. This is not the case with a apex trigger. 

I wrote this lead trigger which assigns the ownership of a lead to current user if status is left msg,follow up . ..etc. As soon as i activate the trigger, connector users assigns the ownership to himself. This is automated. Connector user is a fake user.  Even prospect is not in the pardot, it creates the prospect and assigns to Connector user and updates the lead owner with connector user. It almost feels like, there is a glitch. I tried workflow and process builder to function as my apex trigger but returned same error.  I am very new to apex development. Please take a look at my code. Maybe i am missing something. Thank you very much.
 
trigger trickOnLead on Lead (before insert, before update) { 
   for (Lead ld : Trigger.new) {
     
     if(ld.IsRealOwner__c == True && ld.Status == 'Left Message' && UserInfo.getUserId() !='005U0000005Q12t' ) {
             
             ld.ownerid = UserInfo.getUserId(); 
             
             } else if (ld.IsRealOwner__c = True && ld.Status == 'App Sent' && UserInfo.getUserId() !='005U0000005Q12t') {
             
              ld.ownerid = UserInfo.getUserId(); 
              
             } else if (ld.IsRealOwner__c = True && ld.Status == 'Follow Up' && UserInfo.getUserId() !='005U0000005Q12t') {
             
              ld.ownerid = UserInfo.getUserId(); 
         
       }  else if (ld.IsRealOwner__c = True && ld.Status == 'App Received' && UserInfo.getUserId() !='005U0000005Q12t') {
             
              ld.ownerid = UserInfo.getUserId(); 
              
           }   
}
}