Auto Share Records to Connection using Flow

Use Case: Somewhere a Salesforce Administrator working at some company has Salesforce to Salesforce connection setup with some other company. This Admin got a requirement to automatically share all cases of high priority to connected org.

Note ✍️: This post is for orgs having active Salesforce to Salesforce connection setup.
To know about Salesforce to Salesforce, refer this article here

Key Objects:
PartnerNetworkConnection
– Represents a Salesforce to Salesforce connection between Salesforce organizations.
PartnerNetworkRecordConnection – Represents a record shared between Salesforce organizations using Salesforce to Salesforce.


Object Reference for PartnerNetworkConnection
Object Reference for PartnerNetworkRecordConnection

Solution:

Step 1️⃣: Create a Record-Triggered Flow and choose Case object.

Step 2️⃣: Create Decision element to check Case priority.

Step 3️⃣: Get the connection details using Get Records element.


Note📝: To use the Connection ID, run below query in Developer Console and store the ID in a custom label to use in Get Records element.
Select id, connectionName from PartnerNetworkConnection

Step 4️⃣: Use Decision Element to check any connections found or not.

Step 5️⃣: Using Create Records element share records with Connection.

Final Flow:

Output:

Now create a Case with high priority and check External Sharing related list on Case detail page.

✅ Use the below query to view all the records shared externally to connection.
Select Id, connectionId, Status,LocalRecordId, ParentRecordId, RelatedRecords,PartnerRecordId from PartnerNetworkRecordConnection

Thanks for reading 😊

One thought on “Auto Share Records to Connection using Flow

Leave a reply to Zuhal Kasay Civelek Cancel reply

Design a site like this with WordPress.com
Get started