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 2 Salesforce Auto Push records between Orgs


i am trying to auto push records from one org to another and i have written a trigger on Opportunites and it is working good when the condition is met it is autopushing Opportunites but now i want to push related account and contacts how can i do this

Trigger autoforwardOpportunity on Opportunity(after insert)
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++)
Opportunity acc =[i];
String acId = acc.Id;
System.debug('Value of OpportunityId: '+acId);
for(PartnerNetworkConnection network : connMap)
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AssignedBusinessUnit = acc.Assigned_Business_Unit__c;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit);
if((AssignedBusinessUnit!=Null)&& AssignedBusinessUnit.equalsIgnoreCase('IT')  )
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
Hi Akhil,

The following post has sample code to auto accept Account and Contacts on an ORG:

Pls go through to see if this helps..
Thank You Sonam for giving me the link i will check it out and give it a try.

Miki NagikawaMiki Nagikawa
Hi Akhill,
I am at a similar situation where i need to Auto-Forward Opportunities to our connected ORGs. But the Apex Trigger seems to have difficult time searching Partner Org. Should i put in the Connection Org ID? If so where should i enter that? Any help would be greatful!!