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

Updating chatter for case creation in the customer portal


I need to show update for the salesforce user in the chatter for every case insert and update 
in my customer portal.     for that i worte a trigger in the case object  as 

trigger ChatterUpdate on Case (after insert, after update) {

    List<FeedItem> feedItems = new List<FeedItem>();
    List<Account> lstaccount =[select id,name,IsCustomerPortal from Account];
      //Now loop though the new/updated tasks and create the feed posts
    for (Case cas : {
         for(Account acc: lstaccount){    
        if(acc.IsCustomerPortal == true )  {                               
            FeedItem fitem = new FeedItem();          
            fitem.ParentId =;
            fitem.LinkUrl = '/' +; //This is the url to take the user to the activity
            fitem.Title = 'View';  //This is the title that displays for the LinkUrl           
            fitem.Body = ((Trigger.isInsert)? ' : New Case has been Created ' : ' : Case has been updated')  
                      +  '\nCase with subject  : '+ cas.subject;

    //Save the FeedItems all at once.
    if (feedItems.size() > 0) {
        Database.insert(feedItems,false); //notice the false value. This will allow some to fail if Chatter isn't available on that object

But i'm not getting any update feed in my chatter.

Any idea to solve the problem.     


Have you tried adding some debug to check that you are getting as far as the creation of the feed items?


Ya i'm getting error as follows.


Database.Error[getFields=();getMessage=Entity is read-only:



Even this error is for the customer portal user only. if i create case from my account in salesforce org means i'm not getting error.


That sounds very much like the customer portal doesn't have access to chatter.  I vaguely recall reading something about this - have you checked the licensing?


If that is the case, one workaround may be some scheduled apex that locates all of the cases raised by portal users and creates feed items from those.  It won't be in real time though - the granularity isn't much better than 1 hour I believe.