Using Property Collection in MS CRM 4.0

While using Properties in MS CRM 4.0 one has to be careful as to which dotnet namespace you are instantiating it from. For MS CRM purposes, you need to make sure you instantiate it from Microsoft.crm.sdk and not from System.Data namespace. If you type the following code

PropertyCollection pc_Dummy = new PropertyCollection();

In the above line the word “Property Collection” will be show in Red in the Visual Studio IDE. This can be resolved using the following piece of declaration code.

Microsoft.CRM.sdk.PropertyCollection pc_Dummy = new 
Microsoft.CRM.sdk.PropertyCollection();

we can then use this instance (pc_Dummy) in tandem with the Dynamic Entity to add data in the MS CRM database.

PropertyCollection can add any object of type Property. For our purposes we will add mostly MS CRM based properties like CRMBoolean, CRMNumber, StringProperty and so on. Some of the properties I have worked with are

  1. LookupProperty
  2. KeyProperty
  3. CrmBooleanProperty
  4. StringProperty
  5. CrmDateTimeProperty
  6. CrmDecimalProperty
  7. CrmFloatProperty
  8. CrmNumberProperty
  9. CrmMoneyProperty
  10. PicklistProperty

We have more properties other than the above given list. I will brief it in an another post. I do have an idea to create a new tool for MS CRM 4.0 Data Migration purposes. Once I start giving shape to the tool, you can expect more posts on MS CRM 4.0.

Please do let me know if i have missed something.

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

Comments (1)

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