I'm trying to update a sobject (CollaborationGroupFeed) via apex, but I am unable to update a particular reference field (in this case: CreatedBy).

Here is my code:

CollaborationGroupFeed cgf = [SELECT Id, CreatedById
                                                 FROM CollaborationGroupFeed
                                                 WHERE Id =: feedElement.Id
                                                 LIMIT 1];

                    User u = [SELECT Id, Name FROM User WHERE FirstName = 'Steve' AND LastName = 'Jobs'];
                    cgf.CreatedById = u.Id;
                    update cgf;

Error message: Field is not writeable: CollaborationGroupFeed.CreatedById

  • The actual API Name of the field is CreatedById, not CreatedBy. This field is not writeable.
    – Adrian Larson
    Dec 11, 2015 at 19:10
  • Thanks. I still get an error, but I'll update the question.
    – slim
    Dec 11, 2015 at 19:18
  • Yeah, as I said, this field is not writeable.
    – Adrian Larson
    Dec 11, 2015 at 19:23
  • I think you can open a case to make it writeable, but I am not sure. The real question is, why would you ever want to modify its content?
    – Adrian Larson
    Dec 11, 2015 at 19:23
  • The reason why is I'm writing a trigger to post something in the feed on behalf of someone. Is this not achievable?
    – slim
    Dec 11, 2015 at 19:34

1 Answer 1


As Adrian Larson pointed out, the CreatedById field is not writable.

It is a System Field, and from the documentation on System Fields (emphasis mine)

System Fields: The following fields are read-only fields found on most objects. These fields are automatically updated during API operations. For example, the ID field is automatically generated during a create operation and the LastModifiedDate is automatically updated during any operation on an object.

CreatedByIdis automatically set when the record is inserted.

  • 3
    and furthermore, even using the new permission Set Audit Fields upon Record Creation at developer.salesforce.com/docs/atlas.en-us.api.meta/api/…, you can't set createdById on CollaborationGropupFeed
    – cropredy
    Dec 11, 2015 at 19:54
  • What DOES this permission do then, I fail to see the point of enabling it under System Permissions? Only for dataloader maybe?
    – rmarq423
    Nov 1, 2019 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.