I am working with Dynamics CRM annotation, i developed an external application that use the organization service in order to create new annotation linked to a custom entity and linked to the user based on the user id, by set the CallerId in the organization Service and by set the field "CreatedBy" in the annotation object on create.
The problem is that the annotation is sometimes the value of "Created by" is not correct and it randomly set it by another user.
below used code:
Guid callerID = new Guid(HttpContext.Current.Request.QueryString["CallerId"].ToString());
CrmServiceClient connection = new CrmServiceClient(connectionString);
OrganizationServices = connection.OrganizationServiceProxy;
OrganizationServices.CallerId = new Guid(callerID);
.
.
.
Entity Annotation = new Entity("annotation");
Annotation.Attributes["objectid"] = new EntityReference("RelatedEntityLogical", RelatedEntity.Id);
Annotation.Attributes["objecttypecode"] = RelatedEntity.LogicalName;
.
.
.
Annotation.Attributes["createdby"] = new EntityReference("systemuser", callerID);
OrganizationServices.Create(Annotation);
Any ideas? Thanks
Maybe try this:
Do not set the createdby
attribute - ie remove this line:
Annotation.Attributes["createdby"] = new EntityReference("systemuser", callerID);
Set the CallerId directly on the instance of CrmServiceClient:
connection.CallerId = new Guid(callerID);
Invoke Create
directly from the instance of CrmServiceClient:
connection.Create(Annotation);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.