Dynamics CRM Development Part – 2

After creating CRM environment, now it’s time to start our development.Sometime we need to implement some new functionality in CRM that CRM does not provide OOB. Then crm customization and development comes in picture, so basically we can say that CRM development is a result of our CRM Extension plan. Dynamics CRM is a highly extendable application, we can extend it according to your business needs,for more information you can check Dynamics CRM Extensibility Architecture. We can extend Dynamics CRM using Client Side and Server side code. Java script is used for Client side programming and for server side programming we can use C# or VB.net. we can use crm webservices and API to extend it. Dynamics CRM provided basically three webservice

1      CrmDiscoveryService – used to get organization information

2      CrmService– used to interact with CRM Data

3      MetadataService– used to modify data structure

Now the question is where we can use CRM webservices or API.we have different option, where we can do our development for Dynamics CRM for example

  1. CRM Form and Field events. (for JS code)
  2. Plugin. (for server side code)
  3. Custom workflow. (for server side code)
  4. Custom Integration. (for server side code)

I will discuss on these points one by one in my development series. So let’s start with using CRM form and field events. Dynamics CRM form comes with two basic events Onload and OnSave. you can use Onload event to write JS code for different purpose,for that we use the most important property of CRM form “FormType”, which helps us to detect form’s mode, for example if the form is opened in create mode,update mode,readonly mode etc. you can check FormType property as below


{           // Create mode                  }

else if(crmForm.FormType==2)

{  //Update mode        }

 for all FormType value you can check http://msdn.microsoft.com/en-us/library/cc150873.aspx . Another thing that I want to point out here is that as we can use FormType property to detect form’s mode on onload in the same way we can use Event.mode on onsave event. We can use Event.mode to check for which purpose Onsave event is called. we can use below JS to check event.Mode value on onsave event


For all possible value of Event.mode you can check http://msdn.microsoft.com/en-us/library/cc150868.aspx, another good resource for the same is http://mscrmtools.blogspot.com/2009/01/jscript-know-which-action-raised-onsave.html (thanks to Tanguy,for this wonderful post).

All CRM field comes with onchange event.But you can add another JS event for crm field,  for example if you want to call some code on onclick of crm field you can use as below  code on form load event


{alert(“ Mouse click”);}

I will request you to check http://msdn.microsoft.com/en-us/library/cc150866.aspx for different data types that Dynamics CRM supports you can check.  So Javascript can be used for multipurpose, you can use JS code to retrieve crm data with the help of crmservice refer http://msdn.microsoft.com/en-us/library/cc150864.aspx  to use all crmwebservice method through JS. We can write JS code on ISV.config  file while creating custom button. but while using JS code in ISV.config you should keep in mind to replace some character with their encoded value like below

Character                                          Encode Value

<                                                               &lt;

”                                                                 &quot;

&                                                               &amp;

you can write JS code to load iFrame content dynamically. You can check my various post that I have written to use JS code in Dynamic CRM.

I hope this post will help you to understand basic use of JS in Dynamics CRM development, so in next part I will discuss about plugins.



Filed under CRM Dvelopment Series

2 responses to “Dynamics CRM Development Part – 2

  1. Where’s the part 3, 4, 5… ???

    I need some help for Dynamics CRM Development in the Server Side.

    I trying to use the Visual Studio but i need some support to start…

    I’ll apreciate if somewone help me ! tks !

    • mahenderpal


      I have only written some series for CRM 4.0, I am going to write it for CRM 2011 very soon, please feel free to ask any question regarding CRM development, you can also drop me a mail regarding the same.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s