+ Start a Discussion
Ryan Bobadilla 10Ryan Bobadilla 10 

Need to stop Contact Notification from firing in code!


I'm a bit stuck on this one.  I'm assuming now it's in this class in this part of the code and what I need to do is not to trigger the contact transfer notification even if the owner is NOT Marketo:

  // if the contact owner is marketo do not send auto email
    List <Contact> lstConvertedContacts = new List <Contact> ();
    List <Lead> lstConvertedLeads = [select Id, ConvertedContactId, ConvertedContact.Owner.Name, ConvertedAccount.OwnerId, ConvertedAccount.Owner.IsActive from Lead where Id in :insertedLeads];
    System.debug('===== About to change Owner of Converted Lead');
        System.debug('===== Currently running user name is ' + [select name from user where id=:UserInfo.getUserId()].Name);
        for (Lead nextConvertedLead : lstConvertedLeads) {
      Contact con = new Contact(
            Id = nextConvertedLead.ConvertedContactId,
            OwnerId = nextConvertedLead.ConvertedAccount.OwnerId,
            Contact_Status__c = 'New');{
      System.debug('===== Lead Id: ' + nextConvertedLead.Id + ', Contact Id: ' + con.Id + ', nextConvertedLead.ConvertedContact.Owner.Name: ' + nextConvertedLead.ConvertedContact.Owner.Name);
            System.debug('===== nextConvertedLead.ConvertedContact.Owner: ' + nextConvertedLead.ConvertedContact.Owner);
            if (nextConvertedLead.ConvertedContact.Owner.Name == 'Marketo') {

    System.debug('===========>>> updating the owner on contacts: '+lstConvertedContacts.size());
    if(!lstConvertedContacts.isEmpty()) {
      update lstConvertedContacts;

Anyone able to help here?  


Ryan Bobadilla 10Ryan Bobadilla 10
Anyone?  Still need to stop Contact Owner Transfer notification on auto-convert and ownership change from Marketo to Account Owner ownership.  HELP!