You need to sign in to do that
Don't have an account?

Salesforce 2 salesforce automation using trigger
I am implementing the same Salesforce to Salesforce automate record sharing with Apex Trigger for contact object and its related and master records.
I have did all prerequiste setting for this.
My trigger is firing(after insert, after update) and not giving any error but contact record is not sharing with other org.
Help me regarding it or let me know if i have left any action.
I am mentioning my code here:
Trigger AutoforwardContact on Contact(after Insert,after update){
PartnerNetworkConnection pp =[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection
where ConnectionStatus = 'Accepted' and connectionName = '360DC'];
system.debug('ppppp' + pp);
Id networkId = pp.id;
System.debug('>>>>>>networkId' + networkId);
List<PartnerNetworkRecordConnection> connections = new List<PartnerNetworkRecordConnection>();
for (Contact newTest: Trigger.new) {
PartnerNetworkRecordConnection newConnection = new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newTest.Id,
SendClosedTasks = false,
SendOpenTasks = false,
SendEmails = false,
ParentRecordId = newTest.AccountId);
System.debug('>>>>>>newConnection' + newConnection);
connections.add(newConnection);
}
database.insert(connections);
}
Manuall sharing is working but whenever i try for automate using trigger it is not working.
I have did all prerequiste setting for this.
My trigger is firing(after insert, after update) and not giving any error but contact record is not sharing with other org.
Help me regarding it or let me know if i have left any action.
I am mentioning my code here:
Trigger AutoforwardContact on Contact(after Insert,after update){
PartnerNetworkConnection pp =[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection
where ConnectionStatus = 'Accepted' and connectionName = '360DC'];
system.debug('ppppp' + pp);
Id networkId = pp.id;
System.debug('>>>>>>networkId' + networkId);
List<PartnerNetworkRecordConnection> connections = new List<PartnerNetworkRecordConnection>();
for (Contact newTest: Trigger.new) {
PartnerNetworkRecordConnection newConnection = new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newTest.Id,
SendClosedTasks = false,
SendOpenTasks = false,
SendEmails = false,
ParentRecordId = newTest.AccountId);
System.debug('>>>>>>newConnection' + newConnection);
connections.add(newConnection);
}
database.insert(connections);
}
Manuall sharing is working but whenever i try for automate using trigger it is not working.
Please debug the result of database.insert and see if you are getting errors.