I am trying to add a annotation via code and the annotation adds fine but it won't add the correct CreatedBy user. It just adds the annotation and sets the createdby user to the admin. This is what I am using:
Entity annotation = new Entity("annotation");
annotation["createdby"] = new EntityReference("systemuser", new Guid("2a213502-db00-e111-b263-001ec928e97f"));
annotation["objectid"] = new EntityReference("opportunity", opportunityId);
annotation["subject"] = "Lead Note";
annotation["notetext"] = p.Column_18;
Guid annotationId = lService.Create(annotation);
Do you have to do anything special to add the CreatedBy?
Thanks!
You cannot set createdby in Create or Update. See the description for the attribute createdby. It is not valid for Create or Update. The system will set this attribute to the user which is executing the current request.
You have to use impersonation to create a record in the name of another user. Therefore you have to set the CallerId property to the id of the user which identity you would like to impersonate. See Impersonate Using the ActOnBehalfOf Privilege