how many instances of "e" are there in:
q: copying notes/comments from one sobject to another i am trying to use the below code in my trigger to copy the notes from my custom object to a newly created record on the demand object:
list<note> insertingnotes = new list<note>();
list<note> lstnotes = [select id, title, parentid, lastmodifieddate, createdbyid, body from note where parentid =:rq.id];

for (note eachnote : lstnotes){

    note newdemandnote= new note();
    newdemandnote.body = eachnote.body;                            

    newdemandnote.id = eachnote.id;
    newdemandnote.createdby = string.valueof(eachnote.createdbyid);
    newdemandnote.lastmodifieddate = eachnote.lastmodifieddate;           
    newdemandnote.parentid = newd.id;

    insertingnotes.add(eachnote);                            
    }

if (insertingnotes.size() >0){
    insert insertingnotes;
    }

but i am getting a compile error illegal assignment from string to user on the line 
newdemandnote.createdby = string.valueof(eachnote.createdbyid);

i also tried:
newdemandnote.createdby = eachnote.ownerid;

but no luck!
so what is the correct way to do this?

a: newdemandnote.createdby = string.valueof(eachnote.createdbyid);

change to 
newdemandnote.createdbyid = eachnote.createdbyid;

i believe we can't assign createdbyid field. this field is not writtable. 
you may need to give user to set audit fields permission in user's profile.
i suggest just remove all audit fields lines .. rest code look good to me

a: the correct api name is createdbyid:
newdemandnote.createdbyid = eachnote.createdbyid;

please note that this field is typically not writeable.

user
The total number of "e"s in that passage is one hundred and eighty-eight.
assistant