Monday, April 29, 2013

Security Role Permission for Creating New Users in MS CRM 2011

Today I had an issue about not having the "new" button for a custom role to create new Users in MS CRM 2011. Searching the Internet I have found a article about this issue which solves the problem.

In Business Management Tab should have the following security privileges:
1. Organization Level Security (Green Circle) for Read and Append To privileges for Business Unit entity
2. Organization Level Security (Green Circle) for Read andAppend To privileges for Security Role entity
3. Organization Level Security (Green Circle) for Read, Create, Append andAppend To privileges for User entity
4. Organization Level Security (Green Circle) for Read, Createand Append To privileges for User Settings entity
5. Organization Level Security (Green Circle) for Read License Info underMiscellaneous Privileges
In Customization Tab should have the following security privileges:
1. Organization Level Security (Green Circle) for Read privileges for System Form and View entity

Wednesday, January 23, 2013

Object doesn't support property or method in CRM 2011 Javascript after Rollup 12 or Dynamics CRM December 2012 Service Update

Today a Customer reported an error on a CRM 2011 Online solution. In this solution we were using a grid which is filtered through grid.control.setParameter("fetchXml", fetchXml);. This was not working anymore after the Dynamics CRM December 2012 Service Update.

I was searching the web and finally found the following article:
Obeject does not support the property or method for setParameter method in crm 2011 Javascript


grid.control.setParameter("fetchXml", fetchXml);
This will break the code with the error message "Object doesn't support property or method 'setParameter'"
 


The solution was very simple:
You have to use SetParameter instead of setParameter:
 grid.control.SetParameter("fetchXml", fetchXml);

As you maybe don't know which one will work I did the following:
if (grid.control.setParameter != null && grid.control.setParameter != undefined)
       {
            //Inject the new fetchXml
            grid.control.setParameter("fetchXml", fetchXml);
            //Force the subgrid to refresh
            grid.control.refresh();
        }
        else
        {
            AddDebugMessage("grid.control.setParameter is null or undefined");
            if (grid.control.SetParameter != null && grid.control.SetParameter != undefined)
            {
                //Inject the new fetchXml
                grid.control.SetParameter("fetchXml", fetchXml);
                //Force the subgrid to refresh
                grid.control.refresh();
            }
            else
            {
                AddDebugMessage("
grid.control.SetParameter is null or undefined");
            }

      

By the way AddDebugMessage is my little helper alert message function. It is called if a debug flag is set to true.

Wednesday, June 6, 2012

Hide Add Existing or hide Add New Ribbon Buttons

Today I had to search once more for how to hide the Add Existing or Add New Ribbon Buttons. I found the article "Ribbon Customization Part-10-Hide ‘Add Existing’ button in Dynamics CRM 2011" which helped me in this case.

Here I want to just add the lines to hide the Add Existing or Add New Buttons for custom entities. In the RibbonDiffXml you can simply add:

Hide Add Existing Button:

 <CustomActions>
  <HideCustomAction Location="Mscrm.SubGrid.[yourentityname].AddExistingAssoc" HideActionId="sample.Mscrm.SubGrid.[yourentityname].AddExistingAssoc.HideAction" />
  <HideCustomAction Location="Mscrm.SubGrid.[yourentityname].AddExistingStandard" HideActionId="sample.Mscrm.SubGrid.[yourentityname].AddExistingStandard.HideAction" />
</CustomActions>


Hide Add New Button: 

<CustomActions> 
   <HideCustomAction Location="Mscrm.SubGrid.[yourentityname].AddNewStandard" HideActionId="sample.Mscrm.SubGrid.contact.[yourentityname].HideAction" />
</CustomActions>



Monday, June 4, 2012

Create your own SetMandatory function instead of using setRequiredLevel directly

It happens again and again that I am searching for SetMandatory in the SDK of MS CRM 2011. Yes, there is setRequiredLevel. But I never use the option of 'recommended' in my projects. I my opinion a field is mandatory or not mandatory. So therefore I have created the following function and put it in my global library:

var CRM_REQUIRED_LEVEL_NORMAL = "none";
var CRM_REQUIRED_LEVEL_RECOMMENDED = "recommended";
var CRM_REQUIRED_LEVEL_REQUIRED = "required";


function SetMandatory(vsFieldName, vbTrueFalse)
{
    try
    {
        if (Xrm.Page.getAttribute(vsFieldName) != null)
        {
            var loFieldName = Xrm.Page.getAttribute(vsFieldName);
            AddDebugMessage("Set mandatory field: '" + vsFieldName + "' to: " + vbTrueFalse.toString());

            if (vbTrueFalse)
            {
                loFieldName.setRequiredLevel(CRM_REQUIRED_LEVEL_REQUIRED);
            }
            else
            {
                loFieldName.setRequiredLevel(CRM_REQUIRED_LEVEL_NORMAL);
            }
        }
        else
        {
            throw ("The following field is not on the form: " + vsFieldName);
        }
    }
    catch (e)
    {
        CatchErrorMessage(e);
    }
}


To use the function simply call the function just created:
SetMandatory("yourfieldname", true);

Or to set the required Level to "normal":
SetMandatory("yourfieldname", false);

By the way AddDebugMessage is my little helper alert message function. It is called if a debug flag is set to true.

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.