You need to sign in to do that
Don't have an account?
Jaynandan Prasad 8
How to unit test salesforce to salesforce connection via trigger
How to write the test class for the trigger to automate salesforce to salesforce connection via apex-
here's the trigger
here's the trigger
trigger OrgCaseSync on Case (after insert, after update) { PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']; List<PartnerNetworkRecordConnection> recordConnectionToInsert = new List<PartnerNetworkRecordConnection> (); for (Case cc : Trigger.new){ PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); newrecord.ConnectionId = conn.Id; newrecord.LocalRecordId = cc.id; newrecord.SendClosedTasks = false; newrecord.SendOpenTasks = false; newrecord.SendEmails = false; recordConnectionToInsert.add(newrecord); } if (recordConnectionToInsert.size() > 0){ System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records'); insert recordConnectionToInsert; }
Controller Code
public void connect(){
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection ]);
for(PartnerNetworkConnection network : connMap) {
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = '04P280000008OTXEA2';
newrecord.LocalRecordId = '00128000002tqtD';
newrecord.RelatedRecords = 'Contact,Opportunity';
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
insert newrecord;
}
}
}
Test class code.
@isTest
private class HelloWorldTestClass {
static testMethod void validateHelloWorld() {
testpartnerConnection t = new testpartnerConnection();
t.connect();
}
}
Try with below code it wil help .
Thanks
Manoj
[SELECT id, Status FROM Case WHERE Id = :cs.Id]