+ Start a Discussion
Nilam PatelNilam Patel 

Platform Event - Subscriber as Salesforce Org

Requirment: 
Salesforce Org A : will publish event when a Case is been updated.

Salesforce Org B : Case information sent as event message will be consumed in this org and certain business action are trigger based on the Case info.

What is the Apex Code / Configuration on Salesforce Org B to subscribe for the event and consume events ?

 
Raj VakatiRaj Vakati
 Step 1: Defining Your Platform Event Salesforce Org A : 
Step 2 :  Publishing Platform Events (Salesforce Org A) 
Refer this link 
https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_publish.htm
Step 3 : Subscribe to Platform Event Notifications to Salesforce Org B  which contains Steps 
  •  Create a trigger in  Salesforce Org A event Obejct 
  • This trigger will send details to Salesforce Org By Using REST API ( I can say callouts ) 



 
Nilam PatelNilam Patel
Thank you Raj. Step 3 is bit unclear to me. How do you access Salesforce Org A event Object from Salesforce Org B ?
Raj VakatiRaj Vakati

Subscribe to Platform Event Notifications to Salesforce Org B  which contains Steps 
  1.  Create a trigger in  Salesforce Org A event Object 
// Trigger for listening to Cloud_News events.
trigger CloudNewsTrigger on Cloud_News__e (after insert) {    
   // Iterate through each notification.
    for (Cloud_News__e event : Trigger.New) {

// Code is to send Notifcaiton to ther ORG B 
       SendNotofcationToTherSystem.SendDetails(event);
    }
    
   
}
 2.This trigger will send details to Salesforce Org B By Using REST API ( I can say callouts ) 
public cass SendNotofcationToTherSystem{
// ORG B Autenication code
pulic static void SendDetails(event)
Http h = new Http();
        HttpRequest httpReq = new HttpRequest();
        httpReq.setMethod('GET');
        httpReq.setEndpoint('callout:REST_API1/services/data/v41.0/');
        HttpResponse res = h.send(httpReq);
}
}


 
ChandrakanthChandrakanth
Did anyone got other solutions to this ? @Raj, in this case, how is the platform even different than good old trigger mechanism ? If case is cerated or updated in Org A, just send notification to Org B using call out. But why do we need the use of platform events in this case. Can you please put some light on this ?
Utkarsh Verma 22Utkarsh Verma 22
Same is my question, how can we publish a platform event message(from org A) in such a way that it can be subscribed in another salesforce org(org B). Please any soution to this.