Visual Ribbon Editor: Calling JavaScript function Syntax Error after upgraded to CRM 2011 rollup 12

When I was using Visual Ribbon Editor, I added a group and a button to trigger a JavaScript function in a JavaScript Library, I was using CRM 2011 and rollup 12, I found this:

Issue:

If you upgraded to CRM 2011 rollup 12 already and use Visual Ribbon Editor to create button, and the action of  button is calling a JavaScript function in a JavaScript Library, you might get a JavaScript Syntax Error.

Solution:

Add $webresource: in front of you JavaScript library.

For examples:

in if you JavaScript library name is: myJavaScriptLibrary.js, then should specify like like this:

$webresource:myJavaScriptLibrary.js

hope it helps.

Retrieve Global OptionSet meta data and value

I was working on a Silverlight web resource tool in Dynamics Crm 2011 that can display all global optionset meta data and all optionset values/label for specific global optionset by calling  OrganizationRequest using message name RetrieveOptionSet. Looks like currently there isn’t that much details available for this, even in msdn reference for Micosoft.Xrm.Sdk, it just simply says the RequestName property supporting ‘RetrieveOptionSet’ message name that can be used both  online and offline. I managed to complete this successfully, would like to share in more detail.

1. Retrive all Global OptionSets through OrganizationRequest in Silverlight page

//start...
  try
  {
      OrganizationRequest request = new OrganizationRequest();
      request.RequestName = "RetrieveAllOptionSets";
      request.Parameters = new ParameterCollection();
      request.Parameters.Add(new KeyValuePair<string, object>
             ("RetrieveAsIfPublished", false));
      client.ExecuteCompleted += new EventHandler<ExecuteCompletedEventArgs>
             (ExecuteRetrieveAllOptionSets_ExecuteCompleted);
      client.ExecuteAsync(request);
   }
   catch (FaultException<OrganizationServiceFault> ex)
   {
      ExceptionHandling(ex);
   }
   //continue...
private void ExecuteRetrieveAllOptionSets_ExecuteCompleted
        (object sender, ExecuteCompletedEventArgs response)
{
   try
   {
     ObservableCollection<OptionSetMetadataBase> data = 
      (ObservableCollection<OptionSetMetadataBase>)response.Result.Results[0].Value;
     var values = from d in data
                    orderby d.DisplayName
                    select d;
     // Bind to datagrid
     globalOptionsetData.ItemsSource = values;
   }
   catch (Exception ex)
   {
       ExceptionHandling(ex);
   }
}

2. Retrieve one specific Global OptionSet value/label in Silverlight page

    //start...
    try
    {
        OrganizationRequest request = new OrganizationRequest();
        request.RequestName = "RetrieveOptionSet";        
        request.Parameters = new ParameterCollection();
        request.Parameters.Add(new KeyValuePair<string, object>
                ("Name", globalOptionSetName));
        request.Parameters.Add(new KeyValuePair<string, object>
                ("MetadataId", new Guid("00000000-0000-0000-0000-000000000000")));
        request.Parameters.Add(new KeyValuePair<string, object>
                (RetrieveAsIfPublished", false));
        client.ExecuteCompleted += new EventHandler<ExecuteCompletedEventArgs>
                (ExecuteRetrieveOptionSet_ExecuteCompleted);
        client.ExecuteAsync(request);
    }
    catch (FaultException<OrganizationServiceFault> ex)
    {
        ExceptionHandling(ex);
    }
    //continue...

    private void ExecuteRetrieveOptionSet_ExecuteCompleted(object sender, 
            ExecuteCompletedEventArgs response)
    {
        try
        {
          OptionSetMetadata data=
              (OptionSetMetadata)response.Result.Results[0].Value;
          var values = from d in data.Options
                       orderby d.Value
                       select d;
          //binding to DataGrid
          dataGrid.ItemsSource = values;
        }
        catch (Exception ex)
        {
            ExceptionHandling(ex);
        }
    }

In both cases, available member properties of OptionSetMetadataBase (item 1) and Options (item 2)
can be displayed using e.g. DataGrid.

Dynamics CRM 2011 SPN and Windows Authentication configuration for running custom reports

In Dynamics CRM 2011 on premises environment, any of the out-of-box Dynaimcis CRM 
reports can be run smoothly, however, When running customized report, CRM reports 
the following error in IE: "Reporting Error", "The reoprt cannot be display.
(rsProcessingAborted)".

Also found the following error:
1. Checking CRM trace file on CRM server, it shows:
-<ExceptionType>System.ServiceModel.Security.SecurityNegotiationException, System.
ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</ExceptionType><Message>Authentication failed on the remote side (the stream might
 still be available for additional authentication attempts).</Message>
-Microsoft.Reporting.WebForms.ReportServerException: Microsoft Dynamics CRM has 
experienced an error. Reference number for administrators or support: #888D2128: 
Microsoft.Reporting.WebForms.ReportServerException: Query execution failed for 
dataset 'DSMain'. (rsErrorExecutingCommand) ---> Microsoft.Reporting.WebForms.
ReportServerException: For more information about this error navigate to the report
 server on the local server machine, or enable remote errors

2. Checking the Events Viewer on CRM server shows:
Report render failure. Error: An error has occurred during report processing. 
(rsProcessingAborted) from source MSCRMReporting, eventID 19970

This could happened when Dyanmics CRM 2011 both Web and App tier are deployed on one
server, where report servicing and database tier are deployed on separate server, 
most likely you're also using domain account in CRM app pool instead of standard 
build-in account, at this point, SPN(Service Principal Names) need to be set up for 
the CRM application user account to avoid Kerberos Double Hop issue.

After using setspn tool to setup SPN like this:
setspn -a http/your-crm-server-name domain\crm-user 
setspn -a http/your-crm-server-name(FQDN) domain\crm-user

If CRM still reports the error:
This time checking Events Viewer on CRM server, one more error showing on System 
category: The Kerberos client received a KRB_AP_ERR_MODIFIED error from the server
... from source Security-Kerberos, eventID 4.
Or
Not Authorized
HTTP Error 401. The requested resource requires user authentication.
Then two more things still need to be fixed:
(update: only one of them is needed, the point is to use domain account defined in
AppPool not machine account, iis needs to restart after)
1. Goto IIS manager, and disable kernel mode authentication for this CRM site.
2. Open the ApplicationHost.config file in a text editor. By default, this file is 
located at %windir%\system32\inetsrv\config\.
For all folders under the Default Web Site location path, set the value of the 
WindowsAuthentication element and the useAppPoolCredentials attribute to true. 
For example:
 <system.webServer>
   <security>
      <authentication>
         <windowsAuthentication enabled="true" useAppPoolCredentials="true" />
      </authentication>
   </security>
</system.webServer>
Try run any of customized reports again, they should work like other any our-of-box 
reports.