I am migrating my old database tables to new using migration utility, where
I want to update created by, modified by column in incident entity, CRM 2016.
But it is taking my default service account user into these column.
I have used Organization.svc service to Create request.
AttributeCollection attCollection = new AttributeCollection();
attCollection.Add(new KeyValuePair<string, object>(CaseColumn.OverriddenCreatedOn, Row.CreatedOn));
if (!Row.CreatedBy_IsNull)
{
EntityReference CreatedByReference = new EntityReference();
CreatedByReference.LogicalName = "systemuser";
CreatedByReference.Id = new Guid("2D96B2C4-DAC5-E611-8114-005056BB7CAE");
attCollection.Add(new KeyValuePair<string, object>(CaseColumn.createdby, CreatedByReference));
}
entityCaseIncident.Attributes = attCollection;
OrganizationRequest request = new OrganizationRequest();
request.RequestName = "Create";
request.Parameters = new ParameterCollection();
request.Parameters.Add(new KeyValuePair<string, object>("Target", entity));
OrganizationResponse response = CommonFunctions.serviceProxy.Execute(request);
*This post is locked for comments
string ns = "schemas.microsoft.com/.../Contracts";
OrganizationResponse orgResponse;
using (var scope = new OperationContextScope(CommonFunctions.serviceProxy.InnerChannel))
{
var userHeader = MessageHeader.CreateHeader("CallerId", ns, createdByUserId);
OperationContext.Current.OutgoingMessageHeaders.Add(userHeader);
orgResponse = CommonFunctions.serviceProxy.Execute(Requests);
}
I have used this code and worked for me, I am using CallerId concept, so I have updated caller with created by user.
It seems it worked here:
www.inogic.com/.../change-createdbymodifiedby-field-at-runtime-in-dynamics-crm-plugin
But I'm really not sure what's happening in your code.. You are assigning attCOllection to the attributes of the entytCaseIncident, but, then you are using entity as a target. Are you sure you are using those variables in the right places?
Thanks for reply, but is there any chance or trick that I can do this?
In my business scenario, I am migrating my 2013 project cases to new system using ETL job, where I don't want to change created by user and modified by user names. I am using service organization service, I don't want to change this using SQL database.
Hello,
If I'm not wrong this is usual behavior how it works. The only system field you can set during creation is CreatedOn. To populate it with data pass original createdon to overriddencreatedon. You will not be able to set createdby/modifiedby those fields are populated by system.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156