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

Salesforce to Salesforce trigger help



I've successfully written a trigger to automatically share Account records with related opportunities to partners.  I've written a second trigger on Opportunities that does the same thing.  This is so that once an account is shared, new opportunities also get shared.


The problem is now Opportunity Line Items.   After much fooling around, I've finally got it all configured nicely so that I can share opportunities and opportunity line items manually through the Salesforce UI and the product lines land nicely in the partner system.  However I want to do this by trigger as well, so that not just the opportunity goes, but also the line items.  I feel that if it works manually, the trigger should work but it doesnt.


Here's the trigger.  Any ideas??





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

List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, 
    ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']);

List<PartnerNetworkRecordConnection> pncList = new List<PartnerNetworkRecordConnection>();

    for (Opportunity o : {
        if (o.Originating_System__c == 'CRR' ) {
            for (PartnerNetworkConnection pnc : connMap) {
             PartnerNetworkRecordConnection newOpprecord = new PartnerNetworkRecordConnection(
                        ConnectionId = pnc.Id,
                        LocalRecordId = o.Id,
                        SendClosedTasks = false,
                        SendOpenTasks = false,
                        SendEmails = false,
                        ParentRecordId = o.AccountId,
                        RelatedRecords = 'OpportunityLineItem'
    if (!pncList.isEmpty()) {
        upsert pncList;






I'd love to have a solution here, too.

kalai siva 8kalai siva 8
did any one got the soln