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
Jan_SJan_S 

Site Guest user can't post a Chatter FeedItem

Hello,

 

Does anybody know how to post a chatter FeedItem object from a Site as Guest user? Guest user doesn't have write access to Chatter object and there is no configuration in Salesforce to allow it. Is there any design pattern / solution / workaround to this problem? The easiest way would be to use some kind of System.runAs() method to run my code as system admin, but unfortunately Saleforce supports that only in test methods :-/

 

Thanks in advance for any advice ,

Jan

Ryan-GuestRyan-Guest

I don't believe the guest user is allowed to post chatter updates.

Jan_SJan_S

Yeah, I've already realized that, but I don't even know how to workaround it :-/

 

We have integration with an external system which system calls us through our site (as Guest) and when it calls us we want to report a chatter event.

But as we don't have control over that external system we cannot force it to do any kind of login to salesforce to be authenticated. Maybe we should create a proxy server which accepts the calls and forwards them authenticated?! It seems overkill to me.

Chirag MehtaChirag Mehta

Any solutions or work arounds here?

Jan_SJan_S

My solution (workaround) was to:

1. create an object ChatterFeedItem, where we are storing the new chatter events to be posted

2. create a Schedulable job which processes records in ChatterFeedItem

3. start the job by Administrator to run once a minute

 

Note: to run a job in every minute requires another workaround: in the execute() method do this:

 

global void execute(SchedulableContext sc) {
    // 1. do the job
    doTheJob();
    // 2. schedule a new job for next time
    Datetime nextSchedule = Datetime.now().addMinutes(1);
    scheduleJob(new ChatterJob(), nextSchedule);

    // 3. abort this job
    System.abortJob(sc.getTriggerId());
}

 

Chirag MehtaChirag Mehta

Yes that's the only possible. Long route, but the only route :(

 

Thanks for detailed solution, that will be helpful for others.

gitguygitguy

What about sending an email from the controller to a mail service?  Email handlers run inside a user context.

 

I have that exact problem now.  GitHub is sending my Feedback system commit messages and I want to update the items with the commit messages.

 

Groan.

gitguygitguy

Or another alternative, if its acceptable, is to attach notes to the object.  For some reason that works.