Dynamics CRM 2011 Installation Error The instance name must be the same as computer name

When install Dynamics CRM 2011 Server, you may come across this error on System Checks screen; it is related to Microsoft SQL Server and the information is “The instance name must be the same as computer name.”.

This can happen if you rename the database server computer name after you have installed SQL Server.

1. figure out what is saved in SQL Server:

select @@servername

SP_HELPSERVER


2. figure out the database computer name, Start -> Computer -> Properties

3. drop invalid computer name saved in SQL Server

SP_DROPSERVER "INVALID SERVER NAME"

4. add correct computer name to SQL Server

SP_ADDSERVER "CORRECT SERVER NAME", local

5. restart the MSSQLSERVER service

Dynamics CRM send email within workflow permission trick

When send email within workflow, the email send is executed under the workflow owner. In case that the From of the email is not the same as the workflow owner, in order to send the email successfully, the workflow owner need to be given “Send E-Mail as another user” proviledge; or you have to make sure that the email From user is the same as the workflow owner.

Dynamics CRM 2011 Web Address – Xrm.Page.context.getServerUrl | Record URL(Dynamic) workflow dynamic values

Xrm.Page.context.getServerUrl()

 

{Record URL(Dynamic)(Entity)}

The value returned by previously mentioned two ways can be changed by modify Dynamics CRM Web Address within Deployment Manager.



You can use the following to construct URL in FormLabrary

var serverUrl = document.location.protocol + '//' + document.location.host + '/' + Xrm.Page.context.getOrgUniqueName();

Xrm.Page.context.getServerUrl && Record URL(Dynamic) workflow dynamic values can return the base server URL which can be used either to construct web service URL (SOAP | REST) in FormLibrary or embed Record URL in a workflow.

According to SDK

The URL returned is the standard URL used to access the application. If you access the server locally using http://localhost or use an IP address rather than the actual name of the server, this will not be reflected in the value returned by this function. This means that if you are making web service calls or accessing web resources, Internet Explorer will apply security settings that apply to requests that cross domains. To avoid this, always connect to Microsoft Dynamics CRM using the standard URL.

Dynamics CRM 2011 Portal Development – CrmDataSource

Dynamics CRM 2011 Portal Development

CrmDataSource data source control connects to Dynamics CRM and retrieve EntityCollection

IOrganizationService.RetrieveMultiple(QueryExpression)
IOrganizationService.RetrieveMultiple(QueryByAttribute)

and make it available for other controls to bind to, without requiring code. It supports Select, Create, Update and Delete data.

1. Select

It supports FetchXml and QueryByAttribute to retrieve EntityCollection.

I: FetchXml

FetchXml string can be specified inside <FetchXml></FetchXml> node and parameters can be specified by using <SelectParameters></SelectParameters> node. Parameters in FetchXml must be prefixed with “@” symbol. System.Text.RegularExpressions.Regex.Replace is used to replace the parameter names with a value provided.

Example:


<crm:CrmDataSource ID="CrmDataSource1" runat="server">
 <FetchXml>
 <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
 <entity name="adx_webpage">
 <attribute name="adx_webpageid" />
 <attribute name="adx_name" />
 <attribute name="createdon" />
 <order attribute="adx_name" descending="false" />
 <filter type="and">
 <condition attribute="adx_name" operator="eq" value="@name" />
 </filter>
 </entity>
 </fetch>
 </FetchXml>
 <SelectParameters>
 <asp:Parameter Name="name" DefaultValue="Cases" />
 </SelectParameters>
</crm:CrmDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="CrmDataSource1">

<Columns>
 <asp:BoundField DataField='adx_name' HeaderText="Name" />
 <asp:BoundField DataField='createdon' HeaderText="Created On" />
 </Columns>
 </asp:GridView>

Results:

II: QueryByAttribute

QueryByAttribute can be specified inside <QueryByAttribute></QueryByAttribute> node and parameters can be specified by using <SelectParameters></SelectParameters> node. Parameters specified in QueryByAttribute must be prefixed with “@” symbol.

EntityName, Attributes, Values, ColumnSet, Orders are implicit parameter names, which can be specified as parameter name in <SelectParameters></SelectParameters> node.

While <SelectParameters> can be used to provide values to any parameters defined in <QueryByAttribute></QueryByAttribute> node; <QueryParameters></QueryParameters> values are only added to QueryByAttribute.Attributes and QueryByAttribute.Values.

Example:


<crm:CrmDataSource ID="CrmDataSource1" runat="server">
 <QueryByAttribute EntityName="adx_webpage">
 <Attributes>
 <asp:ListItem Value="@queryAttr"></asp:ListItem>
 </Attributes>
 <ColumnSet>
 <asp:ListItem Value="adx_webpageid"></asp:ListItem>
 <asp:ListItem Value="adx_name"></asp:ListItem>
 <asp:ListItem Value="@timestamp"></asp:ListItem>
 </ColumnSet>
 <Orders>
 <asp:ListItem Text="desc" Value="adx_name"></asp:ListItem>
 </Orders>
 <Values>
 <asp:ListItem Value="Home"></asp:ListItem>
 </Values>
 </QueryByAttribute>
 <SelectParameters>
 <asp:Parameter Name="timestamp" DefaultValue="createdon" />
 <asp:Parameter Name="queryAttr" DefaultValue="adx_name" />
 </SelectParameters>
 <QueryParameters>
 <asp:Parameter Name="adx_name" DefaultValue="Home" />
 </QueryParameters>
 </crm:CrmDataSource>
 <asp:GridView ID="GridView1" runat="server" DataSourceID="CrmDataSource1">
 <Columns>
 <asp:BoundField DataField='adx_name' HeaderText="Name" />
 <asp:BoundField DataField='createdon' HeaderText="Created On" />
 </Columns>
 </asp:GridView>

Result:

2. Update

Dynamics CRM 2011 SDK assembly is .NET 4 assembly using CLR V4 GAC location %windir%\Microsoft.NET\assembly\GAC_MSIL\

Dynamics CRM 2011 SDK assembly is .NET 4 assembly using CLR V4.

CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

Gacutil.exe can be used to install .NET 4 assembly into GAC.

Gacutil.exe (Global Assembly Cache Tool)

The physical location is
%windir%\Microsoft.NET\assembly\GAC_MSIL\

.NET 2 & .NET 3.5 assembly using CLR V2 and the GAC location is
%windir%\assembly\

1. Check assembly CLR version use IL Disassembler

Start -> All Programs -> Microsoft Visual Studio 2010 -> Microsoft Windows SDK Tools -> IL Disassembler -> File -> Open -> Double Click “MANIFEST”

2. Check assembly CLR version use C# code

string assemblyPath = @"D:\sdk 5.0.10\bin\microsoft.xrm.sdk.dll";
string clrVersion = System.Reflection.Assembly.ReflectionOnlyLoadFrom(assemblyPath).ImageRuntimeVersion;
Console.WriteLine(clrVersion);

3. View assembly in .NET 4 GAC using Gacutil.exe

gacutil -l >"D:\gac.txt"

4. View assembly in .NET 4 GAC using Windows Explorer

%windir%\Microsoft.NET\assembly\GAC_MSIL\

Team Foundation 11 Deploy check in policy

Add string value registry key, specify file name of the compiled DLL assembliy and the full path under the following key

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\TeamFoundation\SourceControl\Checkin Policies

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\TeamFoundation\SourceControl\Checkin Policies

Dynamics CRM 2011 Portal Development – SavedQueryDataSource

Dynamics CRM 2011 Portal Development

SavedQueryDataSource data source control connects to Dynamics CRM and retrieve  savedquery entity, convert its fetchxml to QueryExpression, retrieve entities by using IOrganizationService.RetrieveMultiple(QueryExpression) and make these entities available for other controls to bind to, without requiring code. It only supports retrieving data.

It only works with savedquery NOT userquery. Savedquery is available to the entire organization and created using customization; userquery belongs to individual users and created using advanced find user interface.

Example:


<crm:SavedQueryDataSource ID="SavedQueryDataSource1" runat="server" SavedQueryName="Active WebPages">
 </crm:SavedQueryDataSource>
 <asp:GridView ID="GridView1" runat="server" DataSourceID="SavedQueryDataSource1">
 </asp:GridView>

Results:

More Information:

Use Saved Queries in a Portal

Walkthrough: Build a Web Application That Connects to Microsoft Dynamics CRM 2011 Using Developer Extensions

Dynamics CRM 2011 Portal Development – CrmEntityDataSource

Dynamics CRM 2011 Portal Development

CrmEntityDataSource data source control expose a property “DataItem” of type object and make it available for other controls to bind to, without requiring code. It only supports retrieving value from CrmEntityDataSource.DataItem property.

If CrmSiteMapNode is assigned as the value for DataItem property, then the return value will be
new Entity[] { CrmSiteMapNode.Entity },
otherwise it will be
new object[] { CrmEntityDataSource.DataItem }.

DataItem property can be set in the .aspx markup by using ASP.NET Expressions/ExpressionBuilder (e.g. CrmSiteMap Expression).

More information regarding to ASP.NET expression can be found ASP.NET Expressions Overview  and ExpressionBuilder Class.

DataItem property can also be set in the .cs code behind.

Example:


<crm:CrmEntityDataSource ID="CrmEntityDataSource1" runat="server" DataItem='<%$ CrmSiteMap: Current %>'>
 </crm:CrmEntityDataSource>
 <asp:GridView ID="GridView1" runat="server" DataSourceID="CrmEntityDataSource1">
 </asp:GridView>

Result: