Archive for October, 2008

Using Dynamic Entity in MS CRM 4.0

The other day, I was helping my wife with one of the issues she was facing in MS CRM 4.0. The code was basically trying to get an instance to the running crmwebservice and use that instance to create a contact or a update a contact in MS CRM.  The issue we where facing in particular, was a type casting issue where an implicit cast of PropertyCollection to Property was not being done. After some research here and here. We ended up with the following code

StringProperty sp_Field1 = new StringProperty("Field1","Value1");
StringProperty sp_Field2 = new StringProperty("Field2","Value1");
 
// Create the DynamicEntity object.
DynamicEntity contactEntity = new DynamicEntity();
// Set the name of the entity type.
contactEntity.Name = EntityName.contact.ToString();
 
// Set the properties of the contact.
contactEntity.Properties.Add(sp_Field1);
contactEntity.Properties.Add(sp_Field);

Thanks to SaaS Developer and Jude Lee for their help in resolving this issue.

Please note, the above code does not have the full code, like getting the crmwebservice object. That part is for another post. One other thing of importance is there are two PropertyCollection classes, one belongs to the System.Data namespace and other one belongs to Microsoft.CRM.SDK namespace. So when you are declaring an object of PropertyCollection type, ensure you prefix the namespace accordingly.

VN:F [1.8.1_1037]
Rating: 3.0/10 (1 vote cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Google Bookmarks
  • del.icio.us
  • Furl
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • TwitThis
  • Yahoo! Buzz
  • YahooMyWeb

Leave a Comment

Hello World !!!

A big HI to the world. This is my first domain which i plan to fill with information related to programming world. Although there are enough resource’s out there. I plan to put content in this site in such a way that it is easily accessible to anyone out there. Anyways All the best to me with my endeavour, I can only hope for the best ;-) .

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Google Bookmarks
  • del.icio.us
  • Furl
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • TwitThis
  • Yahoo! Buzz
  • YahooMyWeb

Leave a Comment