Search code examples
c#.netdynamics-crm-2011dynamics-crm

CRM : Can not set lastusedincampaign field while creating entity


I am creating a new contact record and I need to set lastusedincampaign field while creating. But my entity is being created with empty lastusedincampaign field. I only can set it programatically with Update method after Create.

Where the problem can be?

P.S.: Creating and then updating my entity record is not a good idea, cause I have about 4k entity records to create at once.

UPDATE 1 (test code):

Entity contact = new Entity("contact");
contact["fullname"] = "New contact";
contact["lastusedincampaign"] = DateTime.UtcNow;
CrmHelper.InitializeCrmService().Create(contact);

Solution

  • Looks like CRM ignores lastusedincampaign attribute like it does a few other during create operation. If you do not want to perform create/update operations at the same time, why don't you create a temporary workflow that would run asynchronously and update the field's value? This way async server takes most of the load and the record creations are faster.

    Side note 4k records is not an awfully lot of records to perform a create/update simultaneously, I have worked with records in the tens of thousands and CRM never bottle necked on me.