function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JoshGuiJoshGui 

Chatter Post from one org to another (org's group) with apex

We'd like to use chatter to log errors, instead of sending emails to ourselves, which is what we do now.  However, we have two different orgs with the same application.  Is it possible for one org to post to another org's group feed (using apex only)?

Best Answer chosen by Admin (Salesforce Developers) 
cloudcodercloudcoder

You would have to use something like Apex REST to achieve this. Depending on the frequency of error notification however, you may want to consider writing the error to a custom object in org A, then use scheduled Apex to sweep that object and push to the other org rather than triggered from the actual feedpost trigger.

 

Also remember you will also need to use @future methods if you are looking at doing callouts from within a trigger. 

All Answers

cloudcodercloudcoder

You would have to use something like Apex REST to achieve this. Depending on the frequency of error notification however, you may want to consider writing the error to a custom object in org A, then use scheduled Apex to sweep that object and push to the other org rather than triggered from the actual feedpost trigger.

 

Also remember you will also need to use @future methods if you are looking at doing callouts from within a trigger. 

This was selected as the best answer
JoshGuiJoshGui

Gotcha - thanks!  Funny we were already considering writing our errors to a custom object, as sending them out as emails before calling some @future methods was giving us some "uncommitted work pending" issues anyway.