Wednesday, May 30, 2012

Dynamics XRM Tools - OData Query Designer

Today I was looking for the OData Query Designer which helped me in the past to generate my JSON or ATOM requests. Now the OData Query Designer has improved and worked for me also in MS CRM 2011 Online. The Query Designer is now part of the Dynamics XRM Tools.



Included in the Dynamics XRM Tools are:
  • OData Query Designer
  • Metadata Browser
  • CRM 4 to CRM 2011 JavaScript Converter
  • Trace Tool (on premise only)
  • Statistics 

If you are using it with another base language than english:
  1. add english as language 
  2. import the solution
  3. change your user options to english
  4. now it should work

For more information please visit dynamicsxrmtools.codeplex.com

Tuesday, May 29, 2012

Custom Time Interval in MS CRM 2011 Activities

I found a jscript solution to create custom time interval in MS CRM 4.0. As I needed it for MS CRM 2011 activities I slightly changed the solution. Standard behaviour is a 30 minute interval. With this solutions you can change it to whatever interval you like.

First add the function to a global jscript library


function SetDateTimeInterval(voDateTimeField, viInterval)
{
    try
    {
        //Check the existence of the datetime field. It may not be included in a quick create form!
        if (voDateTimeField != null)
        {
            if (voDateTimeField.getFormat() == "datetime")
            {
                //The new interval in minutes.
                var lsInterval = viInterval;
                var loTables = document.getElementById("scheduledstart").getElementsByTagName("table");
               
                if ((loTables != null) && (loTables.length > 0))
                {
                    var loTable = loTables[1];
                    //Remove all existing values from the selection box while (table.firstChild != null)
                    {
                        loTable.removeChild(loTable.firstChild);
                    }
                    //Add the new values
                    for (hour = 0; hour < 24; hour++)
                    {
                        for (min = 0; min < 60; min += lsInterval)
                        {
                            var row = loTable.insertRow();
                            var cell = row.insertCell();
                            var time = ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
                            cell.setAttribute("val", time);
                            cell.innerText = time;
                        }
                    }
                }
            }
        }
    }
    catch (e)
    {
        CatchErrorMessage(e);
    }
}


Call the function from a local jscript library e.g. appointment

function SetDateTimeIntervalTo15Min()
{
    try
    {
        var lsFieldStartTime = "scheduledstart";
        var loFieldStartTime = Xrm.Page.getAttribute(lsFieldStartTime);

        //Set Interval to 15 minutes
        var liInterval = 15;

        if (loFieldStartTime != null)
        {
            SetDateTimeInterval(loFieldStartTime, liInterval);
        }
    }
    catch (e)
    {
        CatchErrorMessage(e);
    }
}


Tuesday, May 15, 2012

Fetch XML through Advanced Find

It is small but great feature to use Advanced Find to create your Fetch XML statement. 

1. choose the entity you need
2. add or change the search attributes

3. add or change the columns "Spalten bearbeiten"


4. preview your result using the button "results" / "Ergebnisse"
5. download the Fetch XML / "FetchXML herunterladen"

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="account">
    <attribute name="name" />
    <attribute name="address1_city" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="address1_city" operator="eq" value="Zürich" />
    </filter>
  </entity>
</fetch>


I have used it to create the fetch XML statement for the AddExisting filter.

Wednesday, May 2, 2012

Filter the AddExisting functionality

A great how to article to filter the AddExisting Button with a fetch XML resultset.

 
To build the fetch XML you can use the built in advanced find functionality.