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
PatMcClellan__cPatMcClellan__c 

System Generated Push Notification to Salesforce1

I need to send a push notification to Salesforce1 users when a new record is created (tied to a parent object owned by the respective user.) This should be easy with Process Builder Post to Chatter, or with and APEX trigger that creates a FeedItem record.

The challenge is that the new record the triggers the whole process is created by an incoming REST call, so the createdBy field on those records shows up as [MySiteName] Site Guest User. I have a trigger that fires on the new record insertion, and I need it to create a Chatter Post to notify the appropriate user of the new record. However, because the Context User for the new record is the Site Guest User, they don't have access rights to create the Chatter Post (FeedItem).
 
I know others have already proposed adding a "post as System" capability for Chatter, and I've upvoted the idea. In the meantime, what's a workaround? I've tried Process Builder Post to Chatter, I've tried posting to a group rather than a specific profile, I've tried APEX, I've tried runAs() -- that only works for Test methods, I've tried setting the CreatedById. All result in the same error because of the context user and lack of privileges.
 
What I'm trying to accomplish is Push Notification to Salesforce1 users, and posting to their Chatter profile seemed to be the best tact, but I'm open to other tactics if there are other routes to the push notification. Any ideas?

#pushNotifications #Salesforce1