[Quick Tip] How to Apply Javascript On Business Process Fields

In Dynamics CRM 2013 having control on Business Process fields seems to be impossible. You cannot apply Business Rules on these fields but yet it’s possible to access them via Javascript. I think this can be very useful since it’s very simple to implement. You only have to prefix your field names in the code by header_process_ and let the script execute onLoad and onSave.

For example:

  • Getting field’s control when it’s on the form : Xrm.Page.getControl(“fieldname”);
  • Getting field’s control when it’s on the business process: Xrm.Page.getControl(“header_process_fieldname”);

In the business process suppose you want to update the text field field2 when the value of the boolean field1 is Yes:

function iSaidYes()


//Check the control on the form

if (Xrm.Page.getControl(“header_process_field1”) != null && Xrm.Page.getControl(“header_process_field2”) != null ) {



Xrm.Page.getControl(“header_process_field2”).getAttribute().setValue(“I said Yes”);



Xrm.Page.getControl(“header_process_field2”).getAttribute().setValue(“I said No”);










Set Record Fields Values and Open Views With an URL

In Microsoft Dynamics CRM 2013 you can link an external application or add a button somewhere to access the creation form of an entity or a view with simple querying in the organization URL. Entities and Views can be displayed by passing parameters to the main.aspx page. There are many parameters that can be used (More details here http://msdn.microsoft.com/en-us/library/gg328483.aspx). To open a record or a view, you only need two main parameters:

  • etn: which must contain the entity name (ex: account, contact, opportunity,…)
  • pagetype: this takes only two values:
    • entityrecord: Opens an entity record;
    • entitylist: Opens an entity view.


But how to open a new record with predefined values?

Suppose you want to add a creation button in the CRM to an external application. It may be useful to open the creation form in the CRM with some predefined values. So here is how to set field values by passing parameters directly to the form: In addition to the two parameters presented above (entityrecord and entitylist), the third parameter to consider here is extraqs. The parameters passed to etraqs must first be encoded (See http://msdn.microsoft.com/en-us/library/gg334375.aspx for more details). Passing parameters may be different when the field type is date, lookup or text. For date fields, you should use the text value of the date. Example: Creating an Account with the predefined value “My Account”. The encoded value for the extraqs is name=”My Account” http://YourCRMAddress/main.aspx?/main.aspx?etn=account&extraqs=name%3DMy%20Account&pagetype=entityrecord To set more field values, you should first use the encodeURIComponent function and then copy/paste the result and replace the bold part of the URL above. my account Getting the encodedURIComponent by using Javascript: You can use this to get the encodedURI. In this example I try to get the encodedURI of “name=My Account & numberofemployees=20”. <html> <script> var URI = “name=My Account&numberofemployees=20”; var result = encodeURIComponent(URI); document.write(result); </script> </html> This returns: name%3DMy%20Account%26numberofemployees%3D20 Now let’s use it to set the field values by entering the URL: http://YourCRMAddress/main.aspx?/main.aspx?etn=account&extraqs=name%3DMy%20Account%26numberofemployees%3D20&pagetype=entityrecord Yes it works! my account

How to Change Standard Chart Colours

Have you already wondered how to change Dynamics CRM standard chart colours? You may wish to change these standard colours automatically attributed to charts. So this is possible and can be done by editing the chart XML file after exporting it.

The only thing you need to understand before starting to edit this file is that Dynamics CRM uses RGB Colour Code (More information here http://www.rapidtables.com/web/color/RGB_Color.htm).

Now open your exported chart in any code editor and go to the Chart tag as shown below. The attribute PaletteCustomColors contains a range of default colours used by Dynamics CRM in the order. For example the first one is “91,151,213” which is blue (you can enter this code in the website given above to get the associated colour), and the second one “237,125,49” is orange. So if you want to change colours you only have to select a specific colour to get its RGB code and then replace the one you don’t want to see in your charts by the new colour.

Once colours selected and file updated you can now reimport the file and see the result with the new colours you have chosen!



How to turn Dynamics CRM charts into 3D

Charts in Microsoft Dynamics CRM are by default built in 2D. While working on a sales pipeline for example, you may want to see a chart representing it in 3D instead of 2D. This post gives the answer, and it is not easy at all.

First try to export your chart. This export generates the associated XML file.




Once your XML file is exported, look for the tag <Area3DStyle> and change its attribute “Enable3D” from false to true.




Difference Between Managed And Unmanaged Solutions

msdynA Dynamics CRM Solution can be defined as a set of customizations that can be easily moved from a database to another. Depending on project’s context and whether if your environment is a sandbox or not, you can handle two types of solutions. While a managed solution is like a compiled code, an unmanaged solution can be seen like the source code.

Here are the main differences between a managed solution and an unmanaged solution:

Unmanaged Solution:

  1. Always used in the development environments (sandbox);
  2. Can be edited by customizing existing components or by adding new components;
  3. Deleting an unmanaged solution DOES NOT mean that customizations contained in this solution are deleted from the environment. In fact, all customizations stick in the environment’s default solution

Managed Solution:

  1. Often used by ISVs (Independent Software Vendor) and sometimes can be useful in production environments;
  2. CANNOT be edited once installed in another environment as a managed solution;
  3. Deleting a managed solution automatically deletes from the environment all the customizations and the components contained in this managed solution.

[Dynamics CRM 2013] 2 ways to hide/show a section

While customizing a Dynamics CRM 2013 form, you may need to show/hide some fields or sections. Let’s say that in this latest Dynamics CRM version, things are getting easier and we have 2 ways to do so.

First, you may have noticed it, Dynamics CRM 2013 includes a new feature called “Business Rules” (BR) that makes it easier to do some basic operations that we used to implement using code. For example, Business Rules can help you make conditions to show/hide a field (but not an entire section).


To show/hide a section, there are 2 ways:

1-Using BR: Hiding all the fields contained in a section automatically hides the section. This can be used especially when you have few fields in your section.

CAUTION: When a BR is defined, you should create the “else” BR. That means a BR which shows your fields when your condition is verified and a BR which hides them when your condition is not OK.

2-Using Javascript: You can also show/hide a section using this JS code:

Xrm.Page.ui.tabs.get(“tabname”).sections.get(“sectioname”).setVisible(true);  //Shows a section

Xrm.Page.ui.tabs.get(“tabname”).sections.get(“sectioname”).setVisible(false);  //Hides a section