Happy New Year !!!

Let us welcome 2009 with a big bang and a big heart :) .

I wish all my reader’s a Happy New Year and have rocking new year’s party and a great year ahead :) . Let us give peace a change from this new year and stop fighting over communal and religious issues or any issue for that matter.

Happy New Year again :)

Posted in General | Tagged , , , , | 7 Comments

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.

Posted in MS CRM 4.0, Property Collection | Tagged , , , , , , , , , , , | 1 Comment

Working with Custom Entites in MS CRM 4.0

Working with Custom Entities has been a little tough on me because of the High Learning curve involved.  Finally I did win over and learnt quite a bit about using these entities in custom pages. It’s actually quite simple to work with the custom entities. Here’s a piece of code which will get the custom entity into a dynamic entity for us

//Create of New information the custom entity
DynamicEntity de_Custom = new DynamicEntity();
de_Custom.Name = "CustomEntityName";
de_Custom.Properties = PropertiesCollectionObject;
TargetCreateDynamic tcd_Custom = new TargetCreateDynamic();
tcd_Custom.Entity = de_Custom;
CreateRequest cr_CustomRequest = new CreateRequest();
cr_CustomRequest.Target = tcd_Contact;
CreateResponse cr_CustomResponse = (CreateResponse)
     crm_CreateEntityService.Execute(cr_CustomRequest);

In the second line of the code, is where the magic happens. Here all you have to do is specify the custom/system entity name , when querying the web service, will automatically bind to the entity. PropertiesCollectionObject is a collection of Properties which has all the data (type & value information) which is to be inserted in the entity. Here is an sample of what we will have in the PropertiesCollectionObject

Microsoft.Crm.Sdk.PropertyCollection pc_Properties = new 
     Microsoft.Crm.Sdk.PropertyCollection();
 
StringProperty sp_Prop = new StringProperty();
sp_Prop.Name = "EntityFieldName";
sp_Prop.Value = "ValueToBeInserted;
pc_Properties.Add(sp_Prop);

This property collection will have all the properties like Boolean,Picklist,
Lookup and Number, depending on your requirement. This will get bound with the
property collection in the entity object. When CRMService executes the request
it takes the data and the fieldnames inside these properties and inserts them
accordingly.

Please do let me know if i have missed something.

Posted in MS CRM 4.0 | Tagged , , , , | 2 Comments