+ Start a Discussion
BakTBakT 

Test Class for a trigger that checks if the Account record is from a partner.

I hope somebody will be able to help me with this:

 

I have a trigger on Account that checks if the Account is created from a record forwarded by the partner using Salesforce to Salesforce. I am trying to create a test class for this but unfortunately, I don't think it's possible to create an account record on a test class and tell it that it came from a parter and not created locally. Any help?

UVUV

I guess you would have to create the partner network connection in your test class and then forward the record to your salesforce org to test the trigger.

Sample code-

Public Class S2STest{
public void forwardRec()
{
PartnerNetworkConnection []p=[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where
ConnectionStatus = 'Accepted'];

Account account = new Account();
account.Name = 'xyz';
insert account;

for(PartnerNetworkConnection network : p) 
{
    PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

    newrecord.ConnectionId = network.Id;
    newrecord.LocalRecordId = account.Id;
   
    insert newrecord;

}

BakTBakT

I tried the code above but it forwards the record from my org to another org. What is needed is for a record to be forwarded from another org to my org.