Quick Tip: Cleaning Queue Items

So are you stuck with email queue that has junk of emails you don’t want? And maybe those emails are important to CRM.

Let’s say you have these emails in your Queue (imagine there are a lot many and removing them seems like a big task)


Here’s what to do:

  1. Run a Bulk Delete Job on the following:
    Queue Item entity and the required criteria you want (maybe you want to delete only old Queue Item which you no longer need to convert to other record types)
  2. And submit the job.

Now, even if you delete the Queue Items, the Emails will still remain in CRM in Activities records and those are not lost!

Hope this was helpful! 🙂


Understanding Xrm.Page Object Model

Xrm.Page Namespace

When writing form scripts, we will interact with objects from the Xrm.Page namespace to perform the following actions:

  1. Get/Set attribute values.
  2. Show/Hide user interface elements.
  3. Reference multiple controls per attribute.
  4. Access multiple forms per entity.
  5. Manipulate form navigation items.


Xrm.Page Object Hierarchy

Context – Provides methods to retrieve information specific to an organization, a user, or parameters that were passed to a form as a query string.

Data – Provides access to the entity data and methods to manage data in the form.

UI – Contains methods to retrieve information about the user interface, in addition to collections for several sub components of the form.


Execution Context

When you register a function for an event handler, CRM lets you pass the execution context object as the first parameter to the function.

This object contains methods that allow you to managed variables you wish to share with other event handlers.




  1. Page.data.entity.attributes collection provides access to each entity attribute that is available on the form. Only those attributes that correspond to fields added on the form are available.



  1. controls provides access to each control on the form.
  2. controls provide access to each control that have more than one control for an attribute available on the form.
  3. controls provides a collection of controls found in a section.


  1. items:
  2. Page.ui.navigation.items collection provides access to navigation items that are defined using the navigation area of the form editor.


  1. items:

If multiple forms are associated with an entity, each form can be associated with a security role and if security roles of a user enable users to see more than one form, they can select from a collection of Xrm.Page.ui.formSelector.items. A form definition is available in this case.



  1. Page.ui.tabs provides access to collection of each of the tabs present on the form.



A tab can be organized by using more than one section. The tab sections collection provides access to these sections.


Hope this overview was helpful to you!

Fundamentals of JavaScript CRM Customization

JavaScript form customization is a way to interact with entity forms by using JavaScript that is executed for events that occur on the form.

JavaScript form customizations is one of many options to control business processes.

An advantage of JavaScript Form programming is that they are immediate and doesn’t need data to be submitted.

Frequent tasks performed by using form programming are:

  1. Data Validation.
  2. Automation.
  3. Process enhancement and enforcement.



Scripts can be added on events like




Whereas, tabs have the event


and IFRAMES have an event called




OnLoad Event

OnLoad event occurs after the form has loaded. onLoad event is used to prepare the data in the form for use.


OnSave Event

OnSave event occurs when a form is saved. It does not correspond to standard HTML OnSubmit event. The OnSave event occurs in the following scenarios:

  1. When a user clicks on the save button at the bottom right corner of the screen.
  2. Code executes the Page.data.entity.save method, even when there is no changed data to be saved.
  3. The user navigates away from the page and there is unsaved data to be saved.
  4. When auto-save is enabled, 30 seconds after the data has been changed and there is unsaved data on the form.
  5. Code executes the Page.data.save and even if there is unsaved data on the form.
  6. Code executes the Page.data.refresh method passing true as the first parameter and there is unsaved data on the form.


OnChange Event

OnChange is available for every field. OnChange event requires  two conditions to be true:

  1. The data in the field must change.
  2. The field must lose focus.

There is an exception to the Two-Option (Boolean) fields. OnChange event occurs immediately when the value is changed without requiring to lose focus.

The OnChange event does not occur if the field is changed programmatically using the setValue method. Instead fireOnChange method can be used in code to trigger OnChange event.


TabStateChangeEvent Event

This event occurs when a tab is expanded or collapsed.

This event is important in the case that you want to use script to modify the src property of an IFRAME control.


OnReadyStateComplete Event

This event is fired when contents of an IFRAME have completed loading.



  • JavaScript files for form customization are applied as a Web Resource.
  • Navigate to Settings > Customizations > Customize the System. Then navigate to Web Resources under Components on the left navigation pane of the Default Solution (Default solution here is used as an example).


  • In order to add a JavaScript file, we need to create a new Web Resource.


A new JavaScript file could be uploaded or JavaScript code could be simply written in the Text Editor provided by CRM’s Web Resource.

  • So this way, a new Web Resource of type JavaScript could be created which then can be consumed on CRM Forms for customization purposes.
  • For registering events on OnLoad events, select Form Properties on the form.


  • In Form Properties, Select the form libraries that we want to enable on the form level as shown below.


In the above example, a library called ‘new_sampleScript’ has been included. We can now add Event Listeners (which are the functions in that library) that we want to trigger when the library is loaded.



In the above dialog box, select the library which has the desired javascript file/code.

Enter the name of the function you want to trigger on this event.


As shown above, OnLoad events could be executed using JavaScript.



OnSave event listeners could be bound by simply changing the Event to OnSave as shown below.


For OnChange events, the Field Properties need to be changed. Steps to do so are as follows:

  1. Navigate to the desired field and select its properties.


  1. Follow the steps as illustrated for OnSave and OnLoad events above.
  2. So JavaScript code registered OnChange will get triggered when the field value changes and when the field loses focus (Remember, data needn’t be saved for OnChange events to be fired).

Hope this is useful! 🙂



SiteMap Customization in CRM 2013

What is a SiteMap?

  • The SiteMap is a node in the xml file of an exported unmanaged solution.
  • Navigation using SiteMap is evaluated with our Security Privileges to access a particular Entity in order to display it in the Navigation Menu.
  • If security privilege does not let us ‘Read’ a particular entity which is in the sitemap, the navigation item is not displayed.


Editing the customizations.xml file

  • The file can be fetched from an exported unmanaged solution.
  • We can edit this by using even a simple text editor. But it is recommended that it should be edited in a proper XML schema validator tools.
  • To reflect the changes, import the updated file back in the CRM. In case of any errors, CRM won’t let it get imported and the error message will be shown.


Components of the Navigation Pane

There are default areas on the navigation bar consisting of SFA (SALES), CS (SERVICE), MA (MARKETING), Settings (SETTING), and HLP (HELP).


Once an area is selected, it comes besides the main Microsoft Dynamics CRM button. And hovering over that shows a menu that appears at the bottom. This menu contains the subareas divided into different groups.


Configuration options available using SiteMap

  1. Edit Labels
  • The text displayed is default sitemap uses ResourceId attribute to specify the text. This attribute, however, should not be changed or removed.
  • We can use <Titles> (SiteMap) or <Title> (SiteMap) elements instead to specify the txt we want to use for the organization/solution.
  • Title elements will override ResourceId attribute values.


  1. Add/Change Icons
  • <Area> (SiteMap) and <SubArea> (SiteMap) has a 16×16 icon that is displayed on the navigation. PNG, GIF, JPG image web resource are supported.
    While including the image as a web resource, use ‘$webresource’ directive. This will create a dependency and the web resource will not be deleted until the SiteMap element uses it.


  1. Add/remove elements
  • Copy pasting existing XML elements is recommended as it helps reduce writing erroneous code.
  • In case of removal of elements, the fact that whether changing the security privileges will serve the purpose should be considered.
  • It is recommended to use security privileges to an area/subarea instead of removing elements.


  1. Group Links within Areas
  • <Group> (SiteMap) is used to create groups. For this, <Title> (SiteMap) and <Description> (SiteMap) is used for it to be displayed as a group.
  • Then, edit <Area> (SiteMap) element to add the ShowGroups attribute to True.


  1. Adding New pages to an Area.
  • We can also include Web pages in the navigation bar. For that, <SubArea> (SiteMap) must be used in order to add new pages to an area.
  • To display a custom page in the application, use Url attribute instead of Entity This Url should contain the directive ‘$webresource:’ followed by the location of the HTML web resource. As discussed earlier, using the web resource directive will prevent it from being deleted by forming a dependency. So that it is available whenever the SiteMap requires it.


Manually Editing the SiteMap


  1. The SiteMap firstly needs to be added into the unmanaged solution. This can be done by navigating to Settings > Customizations > Solutions. Then, in Client Extensions, include the SiteMap.
  2. Save the solution and chose to export the solution. A zip file will be downloaded. By extracting its contents, find xml file. SiteMap can be edited using this file.
  3. Find <SiteMap> tag to edit the SiteMap.
  4. Create a new zip file, include the extracted solution with the edited xml file.
  5. In Solutions in CRM 2013, include the zip by choosing it to import as a solution. Finally, publish the customizations and refresh the page to see the modifications.



Encode the Ampersand Character.

When there is an ‘&’ in the URL used in the SiteMap, replace it with “&amp;”. Without this, the XML validation fails and the solution will not be imported.


Example from SDK 2013:



<SubArea Id=”new_customSubArea” Url=”http://mysite/mypage.aspx?parameter1=value&amp;parameter2=value “>


<SubArea Id=”new_customSubArea” Url=”http://mysite/mypage.aspx?parameter1=value&parameter2=value”&gt;


Errors while importing SiteMap

  • The import tool takes care of the XML validation. In case of any errors, the default SiteMap is updated and an error message is thrown. In this case, we must rectify the errors and re import the solution.


XML Elements used in SiteMap

  1. <Area> (SiteMap)

Contains the Areas which appear on the CRM 2013 Navigation Pane.

The syntax is as follows:


<Area URL=”” Id=”” ShowGroups= true|false>




The attributes are as follows:

DescriptionResourceID – For internal use only.

Icon  – A 16×16 resolution image that is shown in the button.

Id – unique identifier in ASCII. Spaces are not allowed.

ResourceId – for internal use only.

ShowGroups – Boolean value to choose whether groups of sub-areas are shown in the navigation pane.

Title – Deprecated. Use <Titles> (SiteMap) and <Title> (SiteMap).

Url – Specifies the CRM for Outlook URL to render for the Outlook folder that represents the Area.



Child Elements – <Titles> (SiteMap), <Descriptions> (SiteMap), <Group> (SiteMap)

Parent Elements – <SiteMap> (SiteMap) – root node.


  1. <SiteMap> (SiteMap)

Defines the root node of the SiteMap used for Navigation.

The syntax is as follows:


<SiteMap Url=””>

<Area />



The attributes are as follows:

Url – Specifies the URL for CRM for Outlook to render.


Child Elements- <Area> (SiteMap)

Parent Element- <SiteMap> (ImportExportXml) the container node for <SiteMap> node within the customization.xml file.



  1. <Titles> (SiteMap)

Specifies a set of localizable titles for the parent element.


<Titles><Title / ><Title>


No attributes are present for this element.

Child Element – Specifies the text in a specific language to be displayed for the parent of the Titles element.

Parent Elements – <Area> (SiteMap), <Group> (SiteMap), <SubArea> (SiteMap).


  1. <Descriptions> (SiteMap)

Specifies a set of localizable descriptions for the parent element.


<Descriptions><Description /></Descriptions>


No attributes are present for this element.

Child Element- <Description> (SiteMap)

Parent Element – <Area> (SiteMap), <Group> (SiteMap), <SubArea> (SiteMap)


  1. <Title> (SiteMap)

Provides  a title in a specified language for the parent element i.e. <Titles> (SiteMap)

The syntax is as follows:

<Title LCID=”” Title=”” />


The attributes are as follows:

LCID – 4 or 5 digit Locale ID for a title.

Title – Text to be displayed.


No child elements exists for this tag.


Parent Elements- <Titles> (SiteMap)



  1. <Description> (SiteMap)

Provides  a description in a specified language for the parent element i.e. <Descriptions> (SiteMap) element.

The syntax is as follows:


<Descriptions LCID=”” Description=”” />


The attributes are as follows:

LCID – 4 or 5 digit Locale ID for a description.

Description – Text to be displayed.


No child elements exists for this tag.


Parent Elements- <Descriptions> (SiteMap)


  1. <SubArea> (SiteMap)

Specifies a navigation option within an <Area> (SiteMap). It defines objects that will be displayed under the selected application.





Client = [“All” | “Outlook” | “OutlookLaptopClient” | “OutlookWorkstationClient” | “Web”]

DescriptionResourceId=”” Entity=”” GetStartedPanePath=”” GetStartedPanePathAdmin=”” GetStartedPanePathAdminOutlook=”” GetStartedPanePathOutlook=”” Icon=”” Id=”” License=”” OutlookShortcutIcon=”” PassParams=[“0” | “1” | “true” | “false”]

ResourceId=”” Sku=[“All” | “OnPremise” | “Live” | “SPLA”] Title=”” Url=””>


<Titles / >

<Descriptions / >

<Privilege / >



The attributes are as follows:

AvailableOffline – Whether SubArea is available offline.

CheckExtensionProperty – Internal use only.

Client – Default. Mulitple specified values can be used.

DescriptionResourceId – Internal use only.

DefaultDashboard – Specifies the GUID of the default dashboard.

Entity – Specifies the value of an Entity.

Icon – Consists of an 18×18 icon image.

Id- Unique identifier.

OutlookShortcutIcon – Specifies the outlook icon used.

PassParams – Specifies whether the organization information and language context passed to the URL.

ResourceId – For internal use only.

Sku – Specifies the versions of MS Dynamics CRM that displays this SubArea.

Url – Specifies a URL of a web resource to display in the main frame of  the application when this subarea is selected.


Child Elements- <Privilege> (SiteMap)

Parent Elements – <Group> (SiteMap)




  1. <Group> (SiteMap)

Holds a group of SubAreas

The syntax is as follows:


<Group DescriptionResourceId=”” Icon=”” Id=”” IsProfile=[“0” | “1” | “true” | “false”] ResourceId=”” Title=”” Url=””>






The attributes are as follows:

DescriptionResourceId – For internal use only.

Icon – Unused.

Id- Unique identifier.

IsProfile – Controls whether this Group represents a user selectable Profile for the workplace.

ResourceId – For internal use.

Url- URL to render for the Outlook folder that represents the Group in CRM for Outlook.


Child Elements – <Descriptions> (SiteMap), <SubArea> (SiteMap), <Titles> (SiteMap)


Parent Elements – <Area> (SiteMap)


  1. <Privilege> (SiteMap)

Controls whether a subarea displayed based on privileges available in any security role assigned to a user.


<Privilege Entity=”” Privilege=[Read|Write|Append|AppendTo|Create|Delete|Share|Assign|All|AllowQuickCampaign|UseInternalMarketing] />


The attributes available are as follows:

Entity- Specifies the entity to check the privileges for.

Privilege – Privilege to check.


No child elements are present.


Parent Elements – <SubArea> (SiteMap)


Pass Parameters to a URL Using SiteMap

We can pass organization information and language context of the user and the language context of the organization for the target application by using PassParams attribute of the <SubArea> (SiteMap)



orgname – Organization Name

userlcid – User Language Code. eg. 1033 for English

orglcid – Organization language code. Eg. 1033 for English.


Without Parameters –


With Parameters –




SiteMap Customizations are carried out with the basic requirement to show the navigation pane in a customized manner to user who have different access privileges to different CRM data.

Hope it helps!