+ Start a Discussion
Aneesha K SAneesha K S 

How to update a record after sharing through S2S

Hi,

 

I have a lead record, which I am sharing through the out-of-box S2S functionality. The process is not manual.

Now I have a req in which I need to update the owner of the lead record after sharing it through S2S. I tried running before update trigger but somehow it is not working. The trigger itself is not running once I click on 'Forward to Connections' button.

Why is the trigger not running.?

 

Given below is my code.

 

trigger LeadOwnerUpdate on Lead (before update)
{
    List<PartnerNetworkRecordConnection> recordConns = new List<PartnerNetworkRecordConnection>();
    List<Group> queue = new List<Group>([select Name,Id from Group g where Name = 'abc' limit 1]);
    System.debug('queue'+queue);
    for(Lead sendRecord : Trigger.new)
    {
        recordConns = [select Id, Status, ConnectionId, LocalRecordId from PartnerNetworkRecordConnection where LocalRecordId =:sendRecord.id];
        System.debug('recordConns '+recordConns);
        for(PartnerNetworkRecordConnection recordConn : recordConns)
        {
             if(recordConn.Status.equalsignorecase('Sent') || recordConn.Status.equalsignorecase('Pending (Sent)') || recordConn.Status.equalsignorecase('Active (Sent)') && sendRecord.Lead_Sub_Source__c != 'abcd')
             { 
                 system.debug('inside if clause');
                 sendRecord.ownerid = queue[0].id;    
             } 
         }
    }
}

 

Please help, I need to update the owner to a queue and I cannot override the 'Forward to Connections' button. Is there any way?