Set Custom View as Default View for Lookup Control


Let’s say we have to set Custom View as Default View of a particular Lookup. Below are the steps to set Custom View as default View.

1. Create a Custom View as per your requirement and Save it.(In my case, Created a custom view of Account which will be shown on contact entity for Primary Customer Field)
CustomView

2. Get View Id from Browser. 3. Download Fetch XML for your custom view as shown below. In my case, below is the FetchXML query..

<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false”>   <entity name=”account”>     <attribute name=”name” />     <attribute name=”primarycontactid” />     <attribute name=”telephone1″ />     <attribute name=”accountid” />     <attribute name=”accountratingcode” />     <order attribute=”name” descending=”false” />     <filter type=”and”>       <condition attribute=”telephone1″ operator=”eq” value=”555-0135″ />     </filter>   </entity> </fetch>

4. Format the FetchXML  as string variable as below.

    var fetchXml = “<fetch version=’1.0′ “ +
 “output-format=’xml-platform’ “ +
 ” mapping=’logical’ “ +
 ” distinct=’false’>” +
  “<entity name=’account’>” +
    “<attribute name=’name’ />” +
    “<attribute name=’primarycontactid’ />” +
    “<attribute name=’telephone1′ />” +
    “<attribute name=’accountid’ />” +
    “<attribute name=’accountratingcode’ />” +
    “<order attribute=’name’ descending=’false’ />” +
    “<filter type=’and’>” +
     ” <condition attribute=’telephone1′ operator=’eq’ value=’555-0135′ />” +
    “</filter>” +
  “</entity>” +
“</fetch>”;
5. Create layoutXml to set Grid properties to display the view as below.
var layoutXml = “<grid name=’resultset’ “ +
“object=’1′ “ +
“jump=’name’ “ +
“select=’1′ “ +
“icon=’1′ “ +
“preview=’1′>” +
“<row name=’result’ “ +
“id=’accountid’>” +
“<cell name=’name’ “ +
“width=’300′ />” +
“<cell name=’primarycontactid’ “ +
“width=’150′ />” +
“<cell name=’telephone1′ “ +
“width=’100′ />” +
“<cell name=’accountratingcode’ “ +
“width=’100′ />” +
“disableSorting=’1′ />” +
“</row>” +
“</grid>”;

6. Call the addCustomView() method of Lookup to set custom view as Default View.

Sets the viewId, viewDisplayName, fetchXml, and layoutXml variables to pass as arguments so that a custom view is added as the default view to the control for the Parent Customer lookup field.

7. Add above steps in a custom function and call it on OnLoad or OnChange as per requirement
function setDefaultCustomView() {
    var viewId = “{00000000-0000-0000-00AA-000010001001}”;
    var viewDisplayName = “Custom Account View”;
    var fetchXml = “<fetch version=’1.0′ ” +
“output-format=’xml-platform’ ” +
” mapping=’logical’ ” +
” distinct=’false’>” +
“<entity name=’account’>” +
“<attribute name=’name’ />” +
“<attribute name=’primarycontactid’ />” +
“<attribute name=’telephone1′ />” +
“<attribute name=’accountid’ />” +
“<attribute name=’accountratingcode’ />” +
“<order attribute=’name’ descending=’false’ />” +
“<filter type=’and’>” +
” <condition attribute=’telephone1′ operator=’eq’ value=’555-0135′ />” +
“</filter>” +
“</entity>” +
“</fetch>”;

    var layoutXml = “<grid name=’resultset’ ” +
“object=’1′ ” +
“jump=’name’ ” +
“select=’1′ ” +
“icon=’1′ ” +
“preview=’1′>” +
“<row name=’result’ ” +
“id=’accountid’>” +
“<cell name=’name’ ” +
“width=’300′ />” +
“<cell name=’primarycontactid’ ” +
“width=’150′ />” +
“<cell name=’telephone1′ ” +
“width=’100′ />” +
“<cell name=’accountratingcode’ ” +
“width=’100′ />” +
“disableSorting=’1′ />” +
“</row>” +
“</grid>”;

Xrm.Page.getControl(“parentcustomerid”).addCustomView(viewId, “account”, viewDisplayName, fetchXml, layoutXml, true); 

}

Note: Pls change the double quote(“) manually before testing the code.

Associate a Security Role on User Creation in CRM 2011 using Async Plugin


Below is the sample code to associate a security role on user creation in CRM 2011. Register the plugin on Post Create of systemuser entity and select execution mode as Asynchronous

 

public void Execute(IServiceProvider serviceProvider)

        {

            // Obtain the execution context from the service provider.

            IPluginExecutionContext context =

                (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

 

            // Get a reference to the organization service.

            IOrganizationServiceFactory factory =

                (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            IOrganizationService service = factory.CreateOrganizationService(context.UserId);

 

 

// The InputParameters collection contains all the data passed in the message request.

            if (context.InputParameters.Contains(“Target”) &&

                context.InputParameters[“Target”] is Entity)

            {

                // Obtain the target entity from the input parameters.

                Entity entity = (Entity)context.InputParameters[“Target”];

 

                // Verify that the target entity represents a systemuser.

                // If not, this plug-in was not registered correctly.

                if (entity.LogicalName != “systemuser”)

                    return;

 

            try

            {

// get user entity record id

Guid userId=(Guid)context.OutputParameters[“id”];

 

//Get Id of Security Role

Guid securityRoleId=new Guid(“<enter guid here>”)

                // Create the request object

// systemusersroles_association relationship.

AssociateRequest addRolesToUser = new AssociateRequest

{

    Target = new EntityReference(“systemuser”, userId),

    RelatedEntities = new EntityReferenceCollection

    {

        new EntityReference(“role”, securityRoleId)

    },

    Relationship = new Relationship(“systemuserroles_association”)

};

 

// Execute the request.

service.Execute(addRolesToUser);

            }

            catch (FaultException<OrganizationServiceFault> ex)

            {

                // Handle the exception.

            }

        }

}

 hope it will help u !

Retrieve Related entity’s field value from client side using oData


Below is the sample of how to retrieve related entity’s field value using oData.

Let’s take a example ..suppose we want to retrieve some field value from SystemUser entity(User Name and EmployeeId) OnLoad of Account where OwnerId of Account is equal to SystemUserId of SystemUser entity.Write below  code on OnLoad of Account entity.

var serverUrl=Xrm.Page.context.getServerUrl();
var ownerId=Xrm.Page.getAttribute(“ownerid”).getValue()[0].id;
var ownerGuid=ownerId.substring(1,ownerId.length-1);

var oDataQuery=serverUrl+”/xrmservices/2011/OrganizationData.svc/SystemUserSet?$select=DomainName,EmployeeId,ParentSystemUserId,AccessMode&$expand=user_accounts&$filter=SystemUserId eq guid'”+ownerGuid+”‘”;

$.ajax(

{
type: “GET”,
contentType: “application/json; charset=utf-8”,
datatype: “json”,
url: oDataQuery,
beforeSend: function(XMLHttpRequest)
{
XMLHttpRequest.setRequestHeader(“Accept”,”application/json”);
},
success: function(data, textStatus, XmlHttpRequest)
{
if(data != null && data.d != null && data.d !=null)
{
var users=data.d.results[0];
var userName=users.DomainName;

//Lookup Manager(ParentSystemUserId)
var managerName=users.ParentSystemUserId.Name;
var managerId= users.ParentSystemUserId.Id;
var managerType=users.ParentSystemUserId.LogicalName;

// OptionSet
var accessMode=users.AccessMode.Value // This will return integer value

var employeeId=users.EmployeeId;
alert(‘User Name : ‘+users.DomainName +’Employee Id :’ +users.EmployeeId);
}
},
error: function(XmlHttpRequest,textStatus,errorThrown)
{
alert(‘oData select failed ‘+ oDataQuery);
}
}
);

Note : don’t forget to load json2.js and jquery1.4.1.min.js  framework on Account Form.

Hope it will help u.

Create CRM records using REST endpoint with Silverlight


The sample will explain …

1. how to perform basic operation Create CRM records using REST endpoint
2. Display the result( created record ) by adding Silverlight web resource(.XAP file) on entity form.

Step 1: Create Silverlight Application project in Visual Studio 2010

Create a Silverlight project in Visual Studio 2010. Follow the following steps to create Silverlight Application

1. Start -> Visual Studio 2010 -> New -> Project ->Silverlight Template -> Silverlight Application
2. Enter name of the Solution as “SilverlightWithCRM2011” and click “OK”.
3.  Select the option selected in below image.
SilverlightApplication_Host

Keep the option checked  “Host the Silverlight application in a new Web site”

4. Click on “Ok” to create the Silverlight Application Project which will be similar to below.
SilverlightApplication

Step 2: Generate the WCF Data Services Client Data Service Class

  1. In Microsoft Dynamics CRM 2011 navigate to Settings. Choose Customizations and then Developer Resources.
  2. Under Service Endpoints, click the Download CSDL link and save the OrganizationData.csdl file to your computer.
  3. In your Visual Studio 2010 Silverlight application project, right-click References, and then click Add Service Reference.
  4. Type the path of the location where you saved the OrganizationData.csdl file in step 2, and then click Go.

Enter an appropriate CrmODataService and then click OK. Below is the sample image.
AddServiceReference

Step 3: Modify the SilverlightWithCRM2011TestPage.html

Modify three lines of auto generated SilverlightWithCRM2011TestPage.html page

1.            The #silverlightControlHost style width is set to 100%.
2.            The script reference to the Silverlight.js file is commented out (or removed). This will be             provided by Microsoft Dynamics CRM.
3.            A script reference to ../ClientGlobalContext.js.aspx was added. This provides access to a                                              context object that is accessed from the code within MainPage.xaml.cs.

Step 4: Add ServiceUtility.cs file into Silverlight application

This static class will provides the functions to retrieve the Server URL. Below is the sample code of ServiceUtility.cs file
using System;
using System.Windows.Browser;
namespace SilverlightWithCRM2011
{
public static class ServerUtility
{
/// <summary>
/// Returns the ServerUrl from Microsoft Dynamics CRM
/// </summary>
/// <returns>String representing the ServerUrl or String.Empty if not found.</returns>
public static String GetServerUrl()
{
String serverUrl = String.Empty;
//Try to get the ServerUrl from the Xrm.Page object
serverUrl = GetServerUrlFromContext();
return serverUrl;
}
/// <summary>
/// Attempts to retrieve the ServerUrl from the Xrm.Page object
/// </summary>
/// <returns></returns>
private static String GetServerUrlFromContext()
{
try
{
// If the Silverlight is in a form, this will get the server url
ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty(“Xrm”);
ScriptObject page = (ScriptObject)xrm.GetProperty(“Page”);
ScriptObject pageContext = (ScriptObject)page.GetProperty(“context”);
String serverUrl = (String)pageContext.Invoke(“getServerUrl”);

//The trailing forward slash character from CRM Online needs to be removed.
if (serverUrl.EndsWith(“/”))
{
serverUrl = serverUrl.Substring(0, serverUrl.Length – 1);
}

return serverUrl;
}
catch
{
return String.Empty;
}
}
}
}

Step 5: Implement DataServiceContextExtension.cs file

The WCF data services client data service classes can cause some undesirable behavior when records are updated. All properties of the record are updated regardless of whether they are changed or not. Furthermore, if an entity is instantiated rather than being retrieved, any properties not set in code will be null. These null values overwrite any existing values for the record. To avoid these issues, do the following steps

using System;
using System.Linq;
using System.Data.Services.Client;
using System.Reflection;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Xml.Linq;
using SilverlightWithCRM2011.CrmODataService;
namespace SilverlightWithCRM2011.CrmODataService
{
partial class ContosoContext
{
#region Methods
partial void OnContextCreated()
{
this.ReadingEntity += this.OnReadingEntity;
this.WritingEntity += this.OnWritingEntity;
}
#endregion

#region Event Handlers
private void OnReadingEntity(object sender, ReadingWritingEntityEventArgs e)
{

                                                ODataEntity entity = e.Entity as ODataEntity;
if (null == entity)
{
return;
}

entity.ClearChangedProperties();
}

private void OnWritingEntity(object sender, ReadingWritingEntityEventArgs e)
{
ODataEntity entity = e.Entity as ODataEntity;
if (null == entity)
{

                                                                return;
}

entity.RemoveUnchangedProperties(e.Data);
entity.ClearChangedProperties();
}
#endregion
}

public abstract class ODataEntity
{
private readonly Collection<string> ChangedProperties = new Collection<string>();
public ODataEntity()

                                {
EventInfo info = this.GetType().GetEvent(“PropertyChanged”);
if (null != info)
{
PropertyChangedEventHandler method = new PropertyChangedEventHandler
this.OnEntityPropertyChanged);

//Ensure that the method is not attached and reattach it
info.RemoveEventHandler(this, method);
info.AddEventHandler(this, method);
}
}

#region Methods

                                public void ClearChangedProperties()
{
this.ChangedProperties.Clear();
}

internal void RemoveUnchangedProperties(XElement element)

{
const string AtomNamespace = “http://www.w3.org/2005/Atom&#8221;;
const string DataServicesNamespace =
http://schemas.microsoft.com/ado/2007/08/dataservices&#8221;;
const string DataServicesMetadataNamespace = DataServicesNamespace + “/metadata”;
if (null == element)
{
throw new ArgumentNullException(“element”);
}

List<XElement> properties = (from c in element.Elements(XName.Get(“content”,
tomNamespace)
).Elements
XName.Get(“properties”, DataServicesMetadataNamespace)).Elements()
select c).ToList();
foreach (XElement property in properties)
{
if (!this.ChangedProperties.Contains(property.Name.LocalName))
{

property.Remove();
}
}
}

private void OnEntityPropertyChanged(object sender,
ystem.ComponentModel.PropertyChangedEventArgs e)
{
if (!this.ChangedProperties.Contains(e.PropertyName))
{
this.ChangedProperties.Add(e.PropertyName);
}
}
#endregion
}
}
For reference, please visit the below URL
http://msdn.microsoft.com/en-in/library/7a31d077-2f18-47d7-8631-
a711717d02a#BKMK_GenerateWCFDataServicesClientClasses

Step 6: Edit the MainPage.xaml file as below

Just added two TextBox and a button to default MainPage.xaml
<UserControl x:Class=”SilverlightWithCRM2011.MainPage”
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml    xmlns:d=http://schemas.microsoft.com/expression/blend/2008    xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006&#8243;
mc:Ignorable=”d”
d:DesignHeight=”300″ d:DesignWidth=”400″>
<Grid x:Name=”LayoutRoot” Background=”White”>
<StackPanel x:Name =”MessagePanel” VerticalAlignment=”Top”/>
<TextBox Name=”lblAccountName” Height=”30″ Width=”130″ Background=”White”
lowDirection=”LeftToRight” TextAlignment=”Left” Margin=”47,110,212,160″ Text=”Account Name”></TextBox>
<TextBox Name=”txtAccountName” Height=”30″ Width=”150″ Background=”LightGray”   FlowDirection=”LeftToRight” TextAlignment=”Left” Margin=”214,110,36,160″></TextBox>

        <Button Name=”btnSubmit” Click=”btnSubmit_Click” Background=”Brown” Height=”30″ Width=”60″ DataContext=”{Binding}” Content=”Submit” Margin=”153,176,187,94″></Button>
</Grid>
</UserControl>

Step 7: Edit the MainPage.xaml .cs file as below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverlightWithCRM2011.CrmODataService;
using System.Threading;

namespace SilverlightWithCRM2011
{
public partial class MainPage : UserControl
{
private SynchronizationContext _syncContext;
private ContosoContext _context;
private String _serverUrl;

public MainPage()
{
InitializeComponent();

}

/// <summary>
/// Creates an Account record in CRM.
/// </summary>
private void BeginCreateAccount()
{
Account newAccount = new Account();
newAccount.Name = txtAccountName.Text;
_context.AddToAccountSet(newAccount);
_context.BeginSaveChanges(OnCreateAccountComplete, newAccount);
}

/// <summary>
/// Callback method invoked when Account is done being created.
/// </summary>
/// <param name=”result”></param>
private void OnCreateAccountComplete(IAsyncResult result)
{
try
{
_context.EndSaveChanges(result);
Account createdAccount = result.AsyncState as Account;
MessagePanel.Children.Add(new TextBlock()
{
Text = String.Format(“Created a new account named \”{0}\”\n\twith AccountId = \”{1}\”.”,
createdAccount.Name, createdAccount.AccountId)
});

//Retrieve the Account just created.
// BeginRetrieveAccount(createdAccount.AccountId);
}
catch (SystemException se)
{
_syncContext.Send(new SendOrPostCallback(showErrorDetails), se);
}
}

/// <summary>
/// Will display exception details if an exception is caught.
/// </summary>
/// <param name=”ex”>An System.Exception object</param>
private void showErrorDetails(object ex)
{
//Assure the control is visible
MessagePanel.Visibility = System.Windows.Visibility.Visible;

Exception exception = (Exception)ex;
String type = exception.GetType().ToString();

MessagePanel.Children.Add(new TextBlock()
{
Text =
String.Format(“{0} Message: {1}”, type, exception.Message)
});

MessagePanel.Children.Add(new TextBlock()
{
Text =
String.Format(“Stack: {0}”, exception.StackTrace)
});

if (exception.InnerException != null)
{
String exceptType = exception.InnerException.GetType().ToString();
MessagePanel.Children.Add(new TextBlock()
{
Text =
String.Format(“InnerException: {0} : {1}”, exceptType,
exception.InnerException.Message)
});
}
}

private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
//Keeps a reference to the UI thread
_syncContext = SynchronizationContext.Current;

//Get the ServerUrl (ServerUrl is formatted differently OnPremise than OnLine)
_serverUrl = ServerUtility.GetServerUrl();

if (!String.IsNullOrEmpty(_serverUrl))
{

//Setup Context
_context = new ContosoContext(
new Uri(String.Format(“{0}/xrmservices/2011/organizationdata.svc/”,

_serverUrl), UriKind.Absolute));

//This is important because if the entity has new
//attributes added the code will fail.
_context.IgnoreMissingProperties = true;

MessagePanel.Children.Add(new TextBlock()
{
Text = “Starting Create Operation.”
});

//Begin the Create, Retrieve, Update, and Delete operations. The operations are chained together
//as each of them is completed.
BeginCreateAccount();
}
else
{
//No ServerUrl was found. Display message.
MessagePanel.Children.Add(new TextBlock()
{
Text =
“Unable to access server url. Launch this Silverlight ” +
“Web Resource from a CRM Form OR host it in a valid ” +
“HTML Web Resource with a ” +
“<script src=’../ClientGlobalContext.js.aspx’ ” +
“type=’text/javascript’></script>”
});
}

}

}
}

Step 8: Now Compile the SilverLight Application Solution

Both project in solution should be build successfully. Now take SilverlightWithCRM2011.xap and SilverlightWithCRM2011TestPage.html and create two Web Resource of type XAP and HTML respectively.

Give the proper name of the Web Resource as below.

1. avs_/SilverlightWithCrm2011TestPage.html

An HTML page can be used to view the Silverlight control outside a form. The only purpose of this web resource is to provide the URL of the server when the Microsoft Silverlight control cannot access it itself through the Xrm.Page.context.getServerUrl when the Silverlight web resource is added in an entity form.

2. avs_/ClientBin/SilverlightWithCRM2011.xap

The name of this web resource just reflects the relative output location of the .xap file in the Microsoft Visual Studio 2010 Silverlight application (version 4) project.

Now publish the both Web Resource

Note: avs_ is the publisher customization prefix

Step 9: Add SilverlightWithCRM2011 web Resource on any entity Form

The Silverlight Application UI looks like below.

SilverlightUI

Step 10: Enter the Account Name and Click on Submit

It will give the output similar to below.

FinalOutput

I hope this will help you 🙂

Share Entity record with Team


          Below is the sample code to share entity record with team in MS CRM 2011

            var teamReference = new EntityReference(“team”, teamId);
            var grantAccessRequest = new GrantAccessRequest
            {
                PrincipalAccess = new PrincipalAccess
                {
                    AccessMask=AccessRights.ReadAccess | AccessRights.WriteAccess,        
                    Principal=teamReference
                },

                Target=new EntityReference(“lead”,recordId)

            };
            service.Execute(grantAccessRequest);

           // Get teamId from below function

private Guid GetTeamId(string teamName,OrganizationService service)
        {
            Guid teamId=Guid.Empty;
            QueryByAttribute query = new QueryByAttribute();
            ColumnSet cols = new ColumnSet();
            cols.AddColumn(“teamid”); 

            query.ColumnSet = cols;
            query.AddAttributeValue(“name”, teamName);
            query.EntityName = “team”; 

            EntityCollection entityCollection = (EntityCollection)service.RetrieveMultiple(query);              
            if (entityCollection.Entities.Count > 0)
            {
                    Entity entity =entityCollection.Entities[0];
                    teamId = entity.Id;
            }
            return teamId;          

        }

I have already posted the same for CRM 4.0. Please find the reference link below.
https://arvindcsit.wordpress.com/2012/02/26/create-contact-and-share-the-record-which-contains-lookuppicklist-and-string-datatype/

 

Connect To Organization Web service in MS CRM 2011


Provide the connection to the server using a connection string. You can find the CrmConnection class in namespace Microsoft.Xrm.Client and dll (Microsoft.Xrm.Client.dll which is avaialbale in sdk/bin folder)

//The following example shows the connection string using Active Directory authentication:

Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(“Url=http://<Crm Server>/<Orgnization Name>;Domain=<contoso>;Username= Abc;Password=Abc;”);

// Create object of Organization Service

OrganizationService service  = new OrganizationService(connection);

Entity entity = new Entity(“lead”);
entity[“subject”] = “Test”;
entity[“firstname”] = “Arvind”;
entity[“lastname”] = “Singh”;
Guid leadId = service.Create(entity);

For details, please go through below link
http://msdn.microsoft.com/en-in/library/gg695810.aspx

hope it helps..

Moving CRM Servers(Application and Database) to New DataCentre


One of our client wanted to move CRM Server from One Data Centre to different data centre but due to some constraint we could not move it by creating New Organization or by new deployment. We had only left option was update IP address manually.

Recently we moved our CRM Server from one data centre to new data centre due to which IP Address of both Application and Database Server was changed. We had updated new IP Address in Registry(MSCRMconfigdb,database,LocalSdkHost,metabase,ServerUrl,SQLRSServerUrl), Application Pool, Web.Config and custom application. But even after updating new IP address on above section  we were getting the following error.

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.23.201.162:80

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.23.201.162:80

Source Error:

An unhandled exception was generated during the execution   of the current web request. Information regarding the origin and location of   the exception can be identified using the exception stack trace below.

Stack Trace:

 
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.23.201.194:80]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: Unable to connect to the remote server]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1868309
   System.Net.HttpWebRequest.GetRequestStream() +13
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
   Microsoft.Crm.Metadata.MetadataWebService.GetDataSet() +31
   Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadDataSetFromWebService(Guid orgId) +291
   Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadCacheFromWebService(LoadMasks masks, Guid organizationId) +42
   Microsoft.Crm.Metadata.DynamicMetadataCacheFactory.LoadMetadataCache(LoadMethod method, CacheType type, IOrganizationContext context) +408
   Microsoft.Crm.Metadata.MetadataCache.LoadCache(IOrganizationContext context) +339
   Microsoft.Crm.Metadata.MetadataCache.GetInstance(IOrganizationContext context) +388
   Microsoft.Crm.BusinessEntities.BusinessEntityMoniker..ctor(Guid id, String entityName, Guid organizationId) +116
   Microsoft.Crm.Caching.UserDataCacheLoader.LoadCacheData(Guid key, ExecutionContext context) +323
   Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context) +401
   Microsoft.Crm.Caching.BasicCrmCache`2.CreateEntry(TKey key, IOrganizationContext context) +84
   Microsoft.Crm.Caching.BasicCrmCache`2.LookupEntry(TKey key, IOrganizationContext context) +135
   Microsoft.Crm.BusinessEntities.SecurityLibrary.GetUserInfoInternal(WindowsIdentity identity, IOrganizationContext context, UserAuth& userInfo) +252
   Microsoft.Crm.BusinessEntities.SecurityLibrary.GetCallerAndBusinessGuidsFromThread(WindowsIdentity identity, Guid organizationId) +179
   Microsoft.Crm.Authentication.CrmWindowsIdentity..ctor(WindowsIdentity innerIdentity, Boolean publishCrmUser, Guid organizationId) +252
   Microsoft.Crm.Authentication.WindowAuthenticationProviderBase.Authenticate(HttpApplication application) +431
   Microsoft.Crm.Authentication.AuthenticationStep.Authenticate(HttpApplication application) +172
   Microsoft.Crm.Authentication.AuthenticationPipeline.Authenticate(HttpApplication application) +86
   Microsoft.Crm.Authentication.AuthenticationEngine.Execute(Object sender, EventArgs e) +525
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

 

Actually It was still referring Old IP Address at some places. To resolve the issue we enable the trace log and get CrmServerReportInformation with help of “Create File” option of  CrmDiagTool 4.0  and came to know that DeploymentProperty Table(Column Name- ADSdkRootDomain, ADWebApplicationRootDomain and AsyncSdkRootDomain) of MSCRM_Config was still referring old IP Address. We have updated this column with new IP Address as below and everything start working fine.

USE MSCRM_CONFIG

Update DeploymentProperties SET NVarCharColumn = ‘New IP Address’  WHERE ColumnName= ‘AsyncSdkRootDomain’

Update DeploymentProperties SET NvarCharColumn = ‘New IP Address’  WHERE ColumnName = ‘ADSdkRootDomain’

Update DeploymentProperties SET NvarCharColumn = ‘New IP Address’  WHERE ColumnName = ‘ADWebApplicationRootDomain’

 

Hope this help you 🙂