CRM 4.0 codename field on Campaign entity

Posted on Posted in MS CRM 4, MS Dynamics

I tried updating codename field’s value on campaign entity in MS Dynamics CRM 4 however it did not save value for codename but was saving everything else.

Tried both in C# and on form (readonly, changed css) but in both cases it kept failing.

code sample

foreach (var camp in _campaigns.ToList())
{

// approach 1

camp.codename = "12345678";
camp.name = "Test Name";
crm.UpdateObject(camp);
crm.SaveChanges();

// approach 2

DynamicEntity _updateCampaign = new DynamicEntity("campaign");
_updateCampaign.Properties.Add(new KeyProperty("campaignid",new Key(camp.campaignid)));
_updateCampaign.Properties.Add(new StringProperty("codename", "9999999"));
_updateCampaign.Properties.Add(new StringProperty("name", "Test Name 2"));
TargetUpdateDynamic update = new TargetUpdateDynamic();
update.Entity = _updateCampaign;
UpdateRequest request = new UpdateRequest();
request.Target = update;
UpdateResponse response = (UpdateResponse)service.Execute(request);

}

Found out that update on codename field is not allowed on campaign entity

https://msdn.microsoft.com/en-us/library/cc151912.aspx