+ Start a Discussion
shahrukh sheikh 7shahrukh sheikh 7 

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

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(); } }
Patcs_1Patcs_1
Hi Shahrukh

you can not  insert an record in PartnerNetworkRecordConnection object.

Here is the link, https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_partnernetworkrecordconnection.htm

In this link, they have mentioned like below

User-added image

If this answered your query, please mark as solution.

Thanks