{"id":319,"date":"2010-08-22T19:19:51","date_gmt":"2010-08-22T19:19:51","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=319"},"modified":"2010-08-22T19:19:51","modified_gmt":"2010-08-22T19:19:51","slug":"dynamics-crm-development-part-2","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=319","title":{"rendered":"Dynamics CRM Development Part \u2013 2"},"content":{"rendered":"<p>After creating CRM environment, now it\u2019s 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.\u00a0Dynamics CRM is a highly extendable application, we can extend it according to your business needs,for more information you can check Dynamics <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd393297.aspx\">CRM Extensibility Architecture<\/a>. 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<\/p>\n<p>1\u00a0\u00a0\u00a0\u00a0\u00a0 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc151013.aspx\">CrmDiscoveryService<\/a> \u2013 used to get organization information<\/p>\n<p>2\u00a0\u00a0\u00a0\u00a0\u00a0 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc151038.aspx\">CrmService<\/a>&#8211; used to interact with CRM Data<\/p>\n<p>3\u00a0\u00a0\u00a0\u00a0\u00a0 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc151047.aspx\">MetadataService<\/a>&#8211; used to modify data structure<\/p>\n<p>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<\/p>\n<ol>\n<li>CRM Form and Field events. (for JS code)<\/li>\n<li>Plugin. (for server side code)<\/li>\n<li>Custom workflow. (for server side code)<\/li>\n<li>Custom Integration. (for server side code)<\/li>\n<\/ol>\n<p>I will discuss on these points one by one in my development series. So let\u2019s 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 \u201cFormType\u201d, which helps us to detect form\u2019s mode, for example if the form is opened in create mode,update mode,readonly mode etc. you can check FormType property as below<\/p>\n<p><strong>if(crmForm.FormType==1)<\/strong><\/p>\n<p><strong>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Create mode\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/strong><\/p>\n<p><strong>else if(crmForm.FormType==2)<\/strong><\/p>\n<p><strong>{\u00a0 \/\/Update mode\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/strong><\/p>\n<p>\u00a0for all FormType value you can check <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc150873.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/cc150873.aspx<\/a>\u00a0. Another thing that I want to point out here is that as we can use FormType property to detect form\u2019s 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\u00a0use below JS to check event.Mode value on onsave event<\/p>\n<p><strong>alert(event.Mode);<\/strong><\/p>\n<p>For all\u00a0possible value of Event.mode you can check\u00a0<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc150868.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/cc150868.aspx<\/a>, another good resource for the same is <a href=\"http:\/\/mscrmtools.blogspot.com\/2009\/01\/jscript-know-which-action-raised-onsave.html\">http:\/\/mscrmtools.blogspot.com\/2009\/01\/jscript-know-which-action-raised-onsave.html<\/a> (thanks to Tanguy,for this wonderful post).<\/p>\n<p>All CRM field comes with onchange event.But you can add another JS event for crm field,\u00a0 for example if you want to call some code on onclick of crm field you can use as below\u00a0 code on form load event<\/p>\n<p><strong>\u00a0crmForm.all.&lt;FieldName&gt;.onclick=function()<\/strong><\/p>\n<p><strong>{alert(\u201c Mouse click\u201d);}<\/strong><\/p>\n<p>I will request you to check <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc150866.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/cc150866.aspx<\/a>\u00a0for different data types that Dynamics CRM supports\u00a0you can check.\u00a0\u00a0So 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 \u00a0to use all crmwebservice method through JS. We can write JS code on ISV.config \u00a0file 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<\/p>\n<p><strong>Character\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Encode Value<\/strong><\/p>\n<p>&lt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &amp;lt;<\/p>\n<p>&#8221;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &amp;quot;<\/p>\n<p>&amp;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 &amp;amp;<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After creating CRM environment, now it\u2019s 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.\u00a0Dynamics CRM is a highly extendable application, we can extend it&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=319\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/319"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}