#region Update the DynamicEntity
// This part of the example demonstrates how to update properties of a
// DynamicEntity.
// Set the contact properties dynamically.
// Contact Credit Limit
CrmMoneyProperty money = new CrmMoneyProperty();
// Specify the property name of the DynamicEntity.
money.Name="creditlimit";
money.Value = new CrmMoney();
// Specify a $10000 credit limit.
money.Value.Value=10000M;
// Contact PreferredContactMethodCode property
PicklistProperty picklist = new PicklistProperty();
// Specify the property name of the DynamicEntity.
picklist.Name="preferredcontactmethodcode";
picklist.Value = new Picklist();
// Set the property's picklist index to 1.
picklist.Value.Value = 1;
// Contact ParentCustomerId property.
CustomerProperty parentCustomer = new CustomerProperty();
// Specify the property name of the DynamicEntity.
parentCustomer.Name = "parentcustomerid";
parentCustomer.Value = new Customer();
// Set the customer type to account.
parentCustomer.Value.type = EntityName.account.ToString();
// Specify the GUID of an existing CRM account.
// SDK:parentCustomer.Value.Value = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC");
parentCustomer.Value.Value = accountID;
// Update the DynamicEntities properties collection to add new properties.
// Convert the properties array of DynamicEntity to an ArrayList.
ArrayList arrProps = new ArrayList(entity.Properties);
// Add properties to ArrayList.
arrProps.Add(money);
arrProps.Add(picklist);
arrProps.Add(parentCustomer);
// Update the properties array on the DynamicEntity.
entity.Properties = (Property[])arrProps.ToArray(typeof(Property));
// Create the update target.
TargetUpdateDynamic updateDynamic = new TargetUpdateDynamic();
// Set the properties of the target.
updateDynamic.Entity = entity;
// Create the update request object.
UpdateRequest update = new UpdateRequest();
// Set request properties.
update.Target = updateDynamic;
// Execute the request.
UpdateResponse updated = (UpdateResponse)service.Execute(update);
#endregion
---------------------------------------------------------------------------------------------
This is nice but my problem stills!!
1) the previous code is an update for money and not for account which is quiet different.
2) imagine i have read my data from csv file in a datatable and i ve fill them in crm by create function. At this step i ve create in crm a new account.
Admitted i ve my datatable and want to map it in crm, but this firma already exists and hat in some records old contain which will be updated, and some are empty, will be filled in and finally some are not exists will be new created.
Question: How i proceed? how can the code look like, i mean test the 3 possiblities(data old, empty or not exist) and for every one write the solution. In another hand how can i in c# compare the records from crm with them of my datatable and vis versa? Do you ve maybe a similar code?
Regards