You need to sign in to do that
Don't have an account?
Raghav T
Not able to Share the Attachments and Task for Case with PartnerNetworkConnection
Hello,
I have created a batch class that will take a case and related case data like task, atttachment, etc.
Then that data is being transfered/Shared with Partner connection.
But on executing the batch class if i comment- down the Task, then the case is shared with partner connection but the Attachments is not.
And if I execute the code with the Task as uncommented the it gives error like this :
Code - Batch Class:
Please guide me in this. Thanks.
I have created a batch class that will take a case and related case data like task, atttachment, etc.
Then that data is being transfered/Shared with Partner connection.
But on executing the batch class if i comment- down the Task, then the case is shared with partner connection but the Attachments is not.
And if I execute the code with the Task as uncommented the it gives error like this :
20:46:15:070 USER_DEBUG [75]|DEBUG|Record Share Error:Insert failed. First exception on row 1; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation: []
Code - Batch Class:
global class SFConnectionFromAToB implements Database.Batchable<sObject> { global Date fromDate= date.newInstance(2023,01,09); global Date toDate; global List <PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>(); global Id connectionId = [Select Id, ConnectionStatus, ConnectionName From PartnerNetworkConnection Where ConnectionName = 'MyConnection' AND ConnectionStatus = 'Accepted'].Id; global Database.QueryLocator start(Database.BatchableContext BC){ system.debug('inside start'); String queryString = 'SELECT Id, (SELECT Id FROM Attachments), (SELECT Id FROM CaseComments), (SELECT Id FROM Events), (SELECT Id FROM Tasks) FROM CASE WHERE Id=\'5002i00000C3e4bAAB\''; system.debug('inside start '+queryString); return Database.getQueryLocator(queryString); } global void execute(Database.BatchableContext BC, List<sObject> scope){ system.debug('inside exec '+scope); for(Case cs : (List<Case>)scope){ prncList.add(new PartnerNetworkRecordConnection( ConnectionId = connectionId, LocalRecordId = cs.Id, SendClosedTasks = true, SendOpenTasks = true, SendEmails = true)); if(!cs.Attachments.isEmpty()){ for(Attachment att : cs.Attachments){ prncList.add(new PartnerNetworkRecordConnection( ConnectionId = connectionId, ParentRecordID = cs.Id, LocalRecordId = att.Id SendEmails = true)); } } if(!cs.Tasks.isEmpty()){ for(Task tsk : cs.Tasks){ prncList.add(new PartnerNetworkRecordConnection( ConnectionId = connectionId, LocalRecordId = tsk.Id, ParentRecordID = cs.Id, SendEmails = true)); } } } if(!prncList.isEmpty()){ try{ system.debug('prncList : '+prncList); upsert prncList; } catch(System.Dmlexception dmlExceptionInstance){ System.debug('Record Share Error:' + dmlExceptionInstance.getMessage()); } } } global void finish(Database.BatchableContext BC){ } }
Please guide me in this. Thanks.
The error message "INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation" suggests that the Partner Network Connection with the name "MyConnection" is not in the correct status to share the data. Please verify if the status of the connection is "Accepted" in Salesforce. Additionally, make sure that the connection is set up correctly and that both parties have granted the necessary permissions to share data.