I am getting an error

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation: []

In my apex test class. i have created an apex batch class for sharing opportunity and have written apex test class for it but i am getting this error. Please suggest if have any solution.

here the test class

@isTest(SeeAllData = true)
public class batchLineItemInsert_Test 
    static testMethod void testMethod1() 

     Account a = new Account(Name='Acme1', BillingCity='San Francisco');
     insert a;

       PartnerNetworkConnection networkConn =[select Id from PartnerNetworkConnection where ConnectionName = 'Services One' and ConnectionStatus = 'Accepted']; 
       PartnerNetworkRecordConnection newConnection1 = new PartnerNetworkRecordConnection(ConnectionId = networkConn.Id, LocalRecordId = a.Id);
       insert newConnection1;       

       Opportunity op1 = new Opportunity(Name='ChildTest123',Accountid=a.Id, StageName='2 - Qualified', CloseDate=System.today() - 50,Expected_Product__c=10.0,error_description__c='error',DealID__c='1',Opportunity_Status__c='Active',Position__c='Ministry of Hajj sasulima');
       op1.CurrencyIsoCode = 'USD';
       insert op1;

       PricebookEntry pbID=  [SELECT Id,Name, PriceBook2Id, Product2Id, CurrencyIsoCode FROM PriceBookEntry where isActive = True and CurrencyIsoCode=:op1.CurrencyIsoCode  limit 1];

       OpportunityLineItem olli = new OpportunityLineItem (Quantity=2, OpportunityId=op1.Id, TotalPrice=10, PriceBookEntryId =pbID.Id); 

        insert olli;

      FF_Batch_details__c ffbd = new FF_Batch_details__c(optyId__c=op1.Id, isActive__c=true, isLineItem__c=true);
        insert ffbd;

       PartnerNetworkRecordConnection newConnection = new PartnerNetworkRecordConnection(ConnectionId = networkConn.Id, LocalRecordId = olli.OpportunityId, ParentRecordId = op1.AccountId);
       insert newConnection;       

        batchLineItemInsert obj = new batchLineItemInsert();


  • Are you using the PartnerNetworkConnection object/type in your code? If so can you share the code? – developer__c Dec 19 '17 at 10:19

You might check to see if a valid template is attached to your connection. The specified partner network status is invalid for the specified template field. Or maybe possibly the record you are attempting to share is not being accepted by the target org.


Really great post on this error that covers a lot of the requirements you must satisfy to avoid this error: http://cropredysfdc.com/2014/11/17/s2s-salesforce-to-salesforce-adventures/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.