Monday, April 25, 2011

System.ServiceModel.EndpointNotFoundException in OWSTIMER.EXE

I started getting this error every five minutes after the timer service would kick off.

An Unhandled exception ('System.ServiceModel.EndpointNotFoundException') occurred in OWSTIMER.EXE

Turns out that the error was due to the Forefront Identity Manager Service not being started.  After starting the service the error goes away.

Tuesday, April 19, 2011

CRM 2011 Publisher Policy / Redirection

While working on a CRM 2011 application I kept getting the following error even though I was not even using the CRM 4.0 SDK file.

Exception information: 
    Exception type: FileLoadException 
    Exception message: Could not load file or assembly 'Microsoft.Crm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

To get around the problem I put the following redirection binding to the CRM 2011 SDK in the web.config. This runtime info can go anywhere directly underneath the configuration node.

     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <assemblyIdentity name="Microsoft.Crm.Sdk"
                           publicKeyToken="31bf3856ad364e35" />
         <bindingRedirect oldVersion=""
                          newVersion="" />

Monday, April 18, 2011

Clear IE Cache Through Command Line

Apparently you can clear the IE cache using the command line.  This is going into batch files to reduce the number of times I have to click in IE.
  • All, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 
  • History, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
  • Cookies, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
  • Temp Internet Files, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
  • Form Data, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
  • Passwords, RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Come Out and See Anne Marie in [title of show]

My lovely wife Anne Marie will be performing in [title of show] at The Little Theatre of Alexandria from April 23-May 14.  If you can make it out to support her I would appreciate it.  I'm planning on attending Easter Sunday, hope to see you there.

[title of show]

Directed by Michael Kharfen
Music and lyrics by Jeff Bowen
Book by Hunter Bell
April 23–May 14, 2011

[title of show] is a unique and quirky musical about two guys who write a Broadway musical about two guys writing a Broadway musical. With a couple of their actress friends, they journey from the unemployment line to the bright lights of Broadway. Don’t miss the show that The New York Times called “...genial, unpretentious and far funnier than many of the more expansively manufactured musicals that make it to Broadway.” This is a 21st century update of “putting on a show” clever songs and witty dialogue. (Strong Language)

Friday, April 15, 2011

CRM 2011 Ribbon XML Tips

  • SharePoint 2010 uses the same ribbon xml schema and there are a lot of resources which are also applicable to CRM 2011. So if a google search using 'CRM 2011 Ribbon' doesn't work try 'SharePoint 2010 Ribbon'.
  • In order to determine sequence numbers you first need to determine the sequence of items currently on the form. You can do this using a tool in the SDK which will allow you do download the ribbon definitions for all of the entities. C:\CRM SDK RC\samplecode\cs\client\ribbon\exportribbonxml\ 
  • NOTE:If you have Many to Many relationships within your custom entities make sure to update the SDK ExportRibbonXML utility to look enture the IsIntersect property is false or the export will fail.
    //Check for custom entities
    RetrieveAllEntitiesRequest raer = new RetrieveAllEntitiesRequest()
    {EntityFilters = EntityFilters.Entity};
    RetrieveAllEntitiesResponse resp = (RetrieveAllEntitiesResponse)_serviceProxy.Execute(raer);
    foreach (EntityMetadata em in resp.EntityMetadata)
      if (em.IsCustomEntity == true)
      entRibReq.EntityName = em.LogicalName;
        if (em.IsIntersect == true) //check to see if the entity is a M2M relationship table
          Console.WriteLine("M2M Entity, " + entRibReq.EntityName + ", will not be exported.");
          RetrieveEntityRibbonResponse entRibResp = (RetrieveEntityRibbonResponse)_serviceProxy.Execute(entRibReq);
          System.String entityRibbonPath = Path.GetFullPath(@"..\..\..\ExportRibbonXml\ExportedRibbonXml\" + 
            em.LogicalName + "Ribbon.xml");
          File.WriteAllBytes(entityRibbonPath, unzipRibbon(entRibResp.CompressedEntityXml));
          //Write the path where the file has been saved.
  • When creating a group only the MaxSize element is required under Scaling unless you want the button to change size based upon the size of the screen.
  • Sequences are extremely important, for example in the following section you will see that a MaxSize has come after a Scale element. This will break the ribbon XML so make sure to look back at the exported ribbon XML from the tool in the SDK to make sure you have all the sequence number correct.
  • Although MaxSize and Scale elements both go underneath the Scaling element you cannot add more than one element at a time under the Scaling element.
  • Example:
    <CustomAction Id="Mscrm.Form.MainTab.Help.Scaling" 
    <Scaling Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Scaling"> 
    <MaxSize Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.MaxSize" Sequence="200" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Large" /> 
    <Scale Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Scale.Medium" Sequence="300" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Medium" /> 
    <Scale Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Scale.Small" Sequence="310" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Small" /> 
    <Scale Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Scale.Popup" Sequence="320" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Popup" /> 
    If you try to import this customization you will get an error in the trace log such as "Crm Exception: Message: The import file is invalid. XSD validation failed with the following error: 'The element 'CommandUIDefinition' has invalid child element 'Scale'.'." Instead what you need to do is break this out into 4 separate Custom Actions
    <CustomAction Id="Mscrm.Form.MainTab.Help.MaxSize" Location="Mscrm.Form.{!EntityLogicalName}.MainTab.Scaling._children" Sequence="500"> 
    <MaxSize Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.MaxSize" Sequence="71" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Large" /> 
    <CustomAction Id="Mscrm.Form.MainTab.Help.Scaling.Medium" Location="Mscrm.Form.{!EntityLogicalName}.MainTab.Scaling._children" Sequence="501"> 
    <MaxSize Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Medium" Sequence="72" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Medium" /> 
    <CustomAction Id="Mscrm.Form.MainTab.Help.Scaling.Small" Location="Mscrm.Form.{!EntityLogicalName}.MainTab.Scaling._children" Sequence="502"> 
    <MaxSize Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Small" Sequence="73" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Small" /> 
    <CustomAction Id="Mscrm.Form.MainTab.Help.Scaling.Popup" Location="Mscrm.Form.{!EntityLogicalName}.MainTab.Scaling._children" Sequence="503"> 
    <MaxSize Id="Mscrm.Form.{!EntityLogicalName}.MainTab.Help.Popup" Sequence="74" GroupId="Mscrm.Form.{!EntityLogicalName}.MainTab.Help" Size="Popup" /> 
  • RuleDefinitions must have the following elements/attributes. Even if there are no rules defined or you are not even adding a Tab they all must be there.

Global Context for CRM 2011

When creating htm pages as webresources in 2011 there are many times you would want to get information about CRM such as the orgname and server url.  This is where the ClientGlobalContext comes in to play.

 <script src="ClientGlobalContext.js.aspx"></script>  

Remember that if the web resource name has a folder name(s) before it you must include preceding "../" in front of the script name.

Example 1:
Webresource Name: mycust_/test.htm
Script reference:
 <script src="../ClientGlobalContext.js.aspx"></script>  

Example 2:

Webresource Name: mycust_/elements/test.htm
Script reference:
 <script src="../../ClientGlobalContext.js.aspx"></script>  

By adding this reference into your htm file you will now have access to several javascript functions:

getAuthenticationHeader: Returns the encoded SOAP header that you need to use Microsoft Dynamics CRM 4.0 Web service calls using Jscript. 

getOrgLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the base language for the organization.

getOrgUniqueName: Returns the unique text value of the organization’s name.

getQueryStringParameters: Returns an array of key value pairs representing the query string arguments that were passed to the page.

getServerUrl: Returns the base server URL. When a user is working offline with Microsoft Dynamics CRM for Microsoft Office Outlook, the URL is to the local Microsoft Dynamics CRM Web services.

getUserId: Returns the GUID value of the for the current user.

getUserLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language.

getUserRoles: Returns an array of strings that represent the GUID values of each security role that the user is associated with.

Additionally this allows for access to some CRM Global Variables:

var USER_GUID='\x7b2CBE7DEF-1141-E011-89F6-A956C6342E5F\x7d';
var ORG_UNIQUE_NAME='test';
var SERVER_URL='https\x3a\x2f\\x2ftest';
var USER_ROLES=['a5201165-7ebd-47dc-af91-3185fc89b077'];
var CRM2007_WEBSERVICE_NS='http\x3a\x2f\\x2fcrm\x2f2007\x2fWebServices';
var CRM2007_CORETYPES_NS='http\x3a\x2f\\x2fcrm\x2f2007\x2fCoreTypes';
var CURRENT_THEME_TYPE='Outlook14Silver';
var CURRENT_WEB_THEME='Default';
var IS_OUTLOOK_14_CLIENT=false;
var IS_ONLINE=true;