I am creating case comment using Apex. I am using the following code to add comment:
CaseComment cc=new CaseComment();
cc.ParentId=obj.Id;
cc.CreatedById='12323re';
cc.CommentBody='test comment';
insert cc;
I am getting the following error on compile time : Field is not writeable: CaseComment.CreatedById
How can i change the Created by of a Case comment?
Case Comment cannot be created by the different user as CreatedById is not a writable field. Salesforce does not allow this for some security reasons. Temporarily, I have stored the commenter information in the comment body and used the information from the comment body for further use.