1

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() 
    {


     Test.startTest();      
     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();
        DataBase.executeBatch(obj); 

         Test.stopTest();


    }
}
  • 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
0

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.

|improve this answer|||||

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.