Monday, 12 September 2011

Installing CRM Server on Multiple Machines

Machine 1: SQL-Server + Reporting Services
SQL Server with reporting services and full text feature on one machine. 
To install reporting extension run SetupSrsDataConnector msi present in SrsDataConnector folder of CRM2011.

Machine 2: Front End
Run SetupServer msi present in CRM2011 extraction files, and when shows the screen of roles select FrontEnd and Depolyment Services
This creates a CRM_Config database on Machine 1, and creates CrmApp application pool, website, and installs webservices.

Machine 3: Backend
Run SetupServer msi present in CRM2011 extraction files, and when prompted for roles select BackEnd and Deployment Services.
When shows the option for new deployment or existing select existing as we have already created from Machine 1. This installs the Async Services and Web services, to run plugin and async operations.


Note: Runing these steps don't install any organisatin, to install organisation run the deployment manager on machine 2.

Sunday, 4 September 2011

Reports in CRM 2011

Run the Report Builder 3.0,
Download "Microsoft SQL Server 2008 R2 Report Builder 3.0"  from http://www.microsoft.com/download/en/details.aspx?id=6116

Connect to Report Server "http://<computername>/reportserver"

Create a Data Source ".;db_mscrm"
Create a new Dataset -> select the above mentioned data source and use the following query
"select column1,column2 from filterednew_customentity" to show records user has access to,
OR
"select column1,column2 from filterednew_customentity as CRMAF_Filterednew_customentity" to show records user has access to and also context sensitive i.e. for the records user selected/or currently viewing entity record.

Drag and drop columns on report, Preview report and then save report

In CRM go to workplace and select reports and click on new 
Report Type: Existing File
File Location: "browse the file created and saved earlier"
Name: Basic Custom Report
Description: Report description
Categories: <<blank>>
Related Records: new_customentity "this is the entity for which the report is created for"
Display In: Forms for related record types;Lists for related record types;Reports area
Save,

Open the form for custom entity and click on Reports button and browse the report.

------------------------------

When creating a custom report for CRM 2011 and using explicit filtering. Create a parameter with the name of CRM_FilteredEntity and type of text, 

In this example, I am trying to create a very basic report where I show statuscode of Cases (Incidents). For that I followed following steps.

1. Created a Parameter of type text with name of CRM_FilteredEntity

2. Created a DataSet with the following query

declare @sql nvarchar(max)
set @sql = 'select statuscode from ('+@CRM_FilteredIncident+') as incident';
exec(@sql) 

and when clicked okay, 
When prompted, I entered "select statuscode from FilteredIncident" to populate dataset with fileds.

3. Draged and drop field on report.




Explicit reports do not include context sensitive records i.e selected records can not be shown in report, however this can be achieved by custom methods e.g creation of ribbon button and then passing selected values to report server url with selected parameters.

http://www.njevity.com/blog/creating-dynamics-crm-2011-reports-sql-reporting-services-pre-filtering-and-default-filters
http://gtcrm.wordpress.com/2011/03/24/fetch-xml-reports-for-crm-2011-online/

----------

When defining data source for the report use embedded option, when report is uploaded to crm or different server, CRM is clever enough to ignore the data source details embedded into report.

How to Enable Tracing in CRM 2011 (Diag Tool)

Sometimes error message from Microsoft CRM is not detailed enough to find the exact root cause. Diagnostic tool is used to write trace log of CRM into files.

Download Diag tool from http://cid-57142f3d072ab525.office.live.com/self.aspx/CRM%202011%20Tools/CrmDiagTool2011.zip

Click on enable tracing.

if tracing is not working after you enabled the tracing, the follow following steps

To enable tracing update registry details

Regedit - take backup of registry before making any changes, just in case...


Computer->HKEY_LOCAL_MACHINE->SOFTWARE->MICROSOFT->MSCRM

Add registry entries if not already exists

Value name = TraceDirctory, Value data =  C:\CRMTrace, Type -- String
Value name = TraceEnabled , Value data 0 ,  Type--DWord (32-bit)
(0:disable, 1: enable)
Value name = TraceRefresh, Value data = 6, Type -- DWord (32-bit)

After updating registry entries, restart IIS.

Here even when specifing tracing info the trace will be written at C:\CRMTrace it been written at
C:\Program Files\Microsoft Dynamics CRM\Trace

Turn off tracing by chaning TraceEnabled registry value to 0

To read the trace log file

http://www.stunnware.com/crm2/topic.aspx?id=tracelogviewer

Thanks


Friday, 1 April 2011

Accessing selected entity Ids from Silverlight

I am opening Silverlight application from contextual custom tab's custom ribbon button.
In this case Xrm.Page.ui and Xrm.Page.data are null as I am not showing Silverlight app as iframe on entity form. Please read Updated post at (http://crm2001andsilverlight.blogspot.com/2011/04/accessing-selected-entity-ids-from.html")

In order to access selected sub grid Ids in Silverlight .

private List<Guid> GetSelectedRecords()
        {
            List<Guid> selectedIds = new List<Guid>();

            HtmlElement gridBodyTable = (HtmlElement)HtmlPage.Window.Eval("dialogArguments.window.document.getElementById(\"gridBodyTable\")");
            if (gridBodyTable != null)
            {
                foreach (var record in gridBodyTable.Children)
                {
                    HtmlElement section = (HtmlElement)record;
                    if (section.TagName.Equals("tbody"))
                    {
                        foreach (var tableRow in section.Children)
                        {
                            HtmlElement row = (HtmlElement)tableRow;
                            if (row.TagName.Equals("tr"))
                            {
                                if (tableRow.GetProperty("selected") != null && (bool) tableRow.GetProperty("selected"))
                                {
                                    var id = tableRow.GetProperty("oid");
                                    if (id != null)
                                    {
                                        selectedIds.Add(new Guid(id as string));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return selectedIds;
        }


Or if anyone interested only in subgrids html from silverlight app  using javascript use
window.dialogArguments.window.document.activeElement.document.body.innerHTML.

Here is another useful link

http://social.microsoft.com/Forums/en/crm2011beta/thread/22d2c422-35c2-43ee-b33a-4bb7f8c36155

Accessing selected entity Ids from Silverlight (Updated)

I was recently involved in implementing a customization of CRM 2011 where I had to perform some actions on displayed subgrid's selected items.

1. Created a new solution and imported entity/ies on which I had to perform action.
2. Imported Application Ribbon
3. Added images as web resources (image being displayed on custom button)
4. Exported solution as unmanaged.

In customizations.xml file of solution,  added following xml to show custom button when subgrid is selected.
<ImportExportXml>
  <Entities>
    <Entity>

        <RibbonDiffXml>
           <CustomActions>
                <CustomAction Id="publishername.Homepage.entityname.CustomTab.Groups" Sequence="40" Location="Mscrm.SubGrid.entityname.MainTab.Workflow.Controls._children">
                  <CommandUIDefinition>
        <Button Id="publishername.Homepage.entityname.CustomTab.FirstGroup.FirstButton" Sequence="11" TemplateAlias="o1" Image32by32="$webresource:publishername_clientemail16.gif" Image16by16="$webresource:publishername_clientemail32.gif" Alt="$LocLabels:publishername.entityname.CustomTab.FirstGroup.FirstButton.LabelText" LabelText="$LocLabels:publishername.entityname.CustomTab.FirstGroup.FirstButton.LabelText" Command="publishername.Homepage.entityname.FirstButton" ToolTipDescription="$LocLabels:publishername.entityname.CustomTab.FirstGroup.FirstButton.ToolTipDescription" ToolTipTitle="$LocLabels:publishername.entityname.CustomTab.FirstGroup.FirstButton.LabelText"/>
      </CommandUIDefinition>
    </CustomAction>
  </CustomActions> -<Templates>
    <RibbonTemplates Id="Mscrm.Templates"/>
  </Templates>
  <CommandDefinitions>
    <CommandDefinition Id="publishername.Homepage.entityname.FirstButton">
      <EnableRules>
        <EnableRule Id="Mscrm.Enabled "/>
      </EnableRules>
      <DisplayRules>
        <DisplayRule Id="publishername.contact.WebClient.DisplayRule"/>
      </DisplayRules>
      <Actions>
        <JavaScriptFunction Library="$webresource:new_javascript" FunctionName="SelectedGridIds">
          <CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
        </JavaScriptFunction>
      </Actions>
    </CommandDefinition>
  </CommandDefinitions> -<RuleDefinitions>
    <TabDisplayRules/> -<DisplayRules>
      <DisplayRule Id="publishername.contact.WebClient.DisplayRule">
        <CrmClientTypeRule Type="Web"/>
      </DisplayRule>
    </DisplayRules> <EnableRules/>
  </RuleDefinitions> -<LocLabels>
    <LocLabel Id="publishername.entityname.CustomTab.FirstGroup.FirstButton.LabelText">
      <Titles>
        <Title languagecode="1033" description="Do Action"/>
      </Titles>
    </LocLabel> -<LocLabel Id="publishername.entityname.CustomTab.FirstGroup.FirstButton.ToolTipDescription">
      <Titles>
        <Title languagecode="1033" description="Perform action on selected items in subgrid"/>
      </Titles>
    </LocLabel>
  </LocLabels>
</RibbonDiffXml>


Above Xml creates a custom button on ribbon when entity subgrid is selected. Sequence defines position of button, and location defines where to show this button on main enity form, grid or subgrid. When button is clicked SelectedGridIds function is executed on new_javascript webresource, all selected ids of subgrids are passed to function defined in Value attribute of CrmParameter.
        <Actions>            
              <JavaScriptFunction Library="$webresource:new_javascript" FunctionName="SelectedGridIds">
                <CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
              </JavaScriptFunction>
            </Actions>

here is javascript I added as webresource 

function SelectedGridIds(selectedIds)
{
  var serverUrl =  Xrm.Page.context.getServerUrl();
   if (serverUrl.match(/\/$/)) {
        serverUrl = serverUrl.substring(0, serverUrl.length - 1);
      }

   //Set features for how the window will appear
    var features = "location=no,menubar=no,status=no,toolbar=no";
  
    var ids="";
    for(var i in selectedIds)
    {
        ids = ids + selectedIds[i] + ",";
    }
     
   if(ids.length >0)
   {
      ids= ids.substring(0,ids.length -1);
   }

    // Open the window
    window.open("/WebResources/new_/SilverlightPage.html#/ViewPage/"+ids, "_blank", features, false);
}

My silverlight application is using Navigation framework, to pass parameters from javascript function to silverlight application I used following mapping
 <uriMapper:UriMapping Uri="/PageView/{ids}" MappedUri="/Views/PageView.xaml?guid={ids}"/>
and finally in order to reterive values with in javascript use Navigation context. NavigationContext.QueryString["ids"].

I am not a blogger, apologies for that.
Suggestions and comments are welcome.