Microsoft MVP 2016 – Business Solutions – Dynamics CRM

indexI am proud to announce that I just received my 1st Microsoft MVP Award for my focus in Business Solutions – Dynamics CRM.

Congratulations! We are pleased to present you with the 2016 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Business Solutions technical communities during the past year.

Also in this email:

About your MVP Award Gift
How to claim your award benefits
Your MVP Identification Number
MVP Award Program Code of Conduct

The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say “Thank you for your technical leadership.”

Patrick Malone
Director
Community & Advocacy Programs
Microsoft

The Microsoft MVP award and the included opportunities add a huge benefit like the Microsoft MVP summit where you have the chance to talk to the Microsoft Product Groups, learn and place feedback. But of course the Microsoft MVP award also adds some other great advantages.

Of course there are a lot of people I have to thank, but I want to keep the list as short as possible. I would like to thank my employer which is supporting me in the best possible way year over year, my current and former colleagues, the Microsoft MVP community and of course Microsoft employees in Redmond and all over the world.

CRM2011/2016 – Timeout problem when open Sharepoint documents from CRM

Today I had a big problem with our new customer: When they tried to open a document from CRM, they had an error:

a

After check a little bit, I found a timeout error on sharepoint.  The problem was the Cookie life time configuration:

[..]When using FBA or a trusted provider, SharePoint will set a cookie on the client called FedAuth. I’ll not go into the details of what’s inside the FedAuth cookie. Of course, the FedAuth cookie will have by default a certain lifetime. Session cookies can be configured too making the cookie invalid after the closing the browser and then bypassing the value in this settings.

The default value is 5 days.[..] (Microsoft text)

cp1

To resolve the problem I found this script:

$sts = Get-SPSecurityTokenServiceConfig
$sts.CookieLifetime = New-TimeSpan -Hours 7
$sts.Update()

At the end I restart IIS and all is run in right way.

#CRM2016 – Get all teams by user in C#

public Microsoft.Xrm.Sdk.EntityCollection UserTeams(Guid UserID)
{

    QueryExpression query = new QueryExpression("team");
    query.ColumnSet = new ColumnSet(true);
    LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");
    link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, UserID));

    try
    {
      return service.RetrieveMultiple(query);
    }
    catch (Exception ex)
    {
       // Do your Error Handling here
       throw ex;
    }
}

CRM2016 – Check if User is a mamber of a team C#

The code is the following:

public static bool IsTeamMember(Guid teamID, Guid userID, IOrganizationService service)
{
QueryExpression query = new QueryExpression("team");
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition(new ConditionExpression("teamid", ConditionOperator.Equal, teamID));
LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");
link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, userID));
var results = service.RetrieveMultiple(query);
 
if (results.Entities.Count > 0)
{
return true;
}
else
{
return false;
}
}

CRM 2016 – Get all activities related with a user with C#

Today I need to get all activities related with a specific user. The way it to easy: We can use FetchXM or Query Expression. I usually prefer use Query Expression.
The code is easy:

private List<Entity> GetAssociatedActivities(EntityReference regarding)
        {
            QueryExpression query = new QueryExpression { EntityName = "activitypointer", ColumnSet = new ColumnSet(new string[] { "activitytypecode" }) };
            query.Criteria.AddCondition("regardingobjectid", ConditionOperator.Equal, regarding.Id);
            query.Criteria.AddCondition("statecode", ConditionOperator.NotEqual, 1);  //ignore completed
            EntityCollection collection = _sdk.RetrieveMultiple(query);
            return collection.Entities.ToList();
        }

That’s all.

CRM2011 – Sql Timeout during the export solution

Another day, another problem to resolve: Last Friday I tried to export a solution as usual but after several minutes I did not have my solution package. I opened the CRM Server and I started to check the Event Viewer. Inside the EventViewer I had this error:

RequestUrl: d2devcrm02/…/dlg_exportsolution.aspx;command=exportsolution&ismanaged=0&optionxml=%3csettings%3e%3cexportAutoNumber%3efalse%3c%2fexportAutoNumber%3e%3cexportCalendar%3efalse%3c%2fexportCalendar%3e%3cexportCustomization%3efalse%3c%2fexportCustomization%3e%3cexportEmailTracking%3efalse%3c%2fexportEmailTracking%3e%3cexportGeneral%3efalse%3c%2fexportGeneral%3e%3cexportMarketing%3efalse%3c%2fexportMarketing%3e%3cexportOutlookSynchronization%3efalse%3c%2fexportOutlookSynchronization%3e%3cexportRelationshipRole%3efalse%3c%2fexportRelationshipRole%3e%3cexportIsvConfig%3efalse%3c%2fexportIsvConfig%3e%3c%2fsettings%3e, StackTrace: [CrmException: SQL timeout expired.]
   at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()
   at Microsoft.Crm.Application.Platform.ServiceCommands.ExportSolutionCommand.Execute()
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ExportSolution(String ismanaged, String optionXml)
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ConfigureForm()
   at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

[HttpUnhandledException: Exception of type ‘System.Web.HttpUnhandledException’ was thrown.]
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 13.06.2016 16:06:31
Event time (UTC): 13.06.2016 14:06:31
Event ID: 32a2c5bc89a145d7bf49d70c8d8f4f28
Event sequence: 616
Event occurrence: 1
Event detail code: 0
 
Application information:
    Application domain: /LM/W3SVC/1/ROOT-1-131102998861671990
    Trust level: Full
    Application Virtual Path: /
    Application Path: C:\Program Files\Microsoft Dynamics CRM\CRMWeb\
    Machine name: D2DEVCRM02
 
Process information:
    Process ID: 4332
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE
 
Exception information:
    Exception type: CrmException
    Exception message: SQL timeout expired.
   at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()
   at Microsoft.Crm.Application.Platform.ServiceCommands.ExportSolutionCommand.Execute()
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ExportSolution(String ismanaged, String optionXml)
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ConfigureForm()
   at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 
 
Request information:
    Request URL: d2devcrm02/…/dlg_exportsolution.aspx{E78FB0AD-C209-45F2-B3C2-969B588AE213}&command=exportsolution&ismanaged=0&optionxml=<settings><exportAutoNumber>false</exportAutoNumber><exportCalendar>false</exportCalendar><exportCustomization>false</exportCustomization><exportEmailTracking>false</exportEmailTracking><exportGeneral>false</exportGeneral><exportMarketing>false</exportMarketing><exportOutlookSynchronization>false</exportOutlookSynchronization><exportRelationshipRole>false</exportRelationshipRole><exportIsvConfig>false</exportIsvConfig></settings>
    Request path: /winVSNextCommissioning/_grid/cmds/dlg_exportsolution.aspx
    User host address: 10.20.180.16
    User: META10\crmdeploymentadmin
    Is authenticated: True
    Authentication Type: Negotiate
    Thread account name: NT AUTHORITY\NETWORK SERVICE
 
Thread information:
    Thread ID: 21
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()
   at Microsoft.Crm.Application.Platform.ServiceCommands.ExportSolutionCommand.Execute()
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ExportSolution(String ismanaged, String optionXml)
   at Microsoft.Crm.Dialogs.ExportSolutionPage.ConfigureForm()
   at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
 
Custom event details:

After a scounting on google I found that there are a number of causes for this error message and there are many article about the problem. I added the the OLEDBTimeout and the ExtendedTimeout registry subkeys to increase the time-out values

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM
  3. Right-click MSCRM, point to New, and then click DWORD Value to create a new DWORD value.
  4. Rename the DWORD value to the following value:
    OLEDBTimeout
  5. Right-click the DWORD value, and then click Modify.
  6. In the Edit DWORD Value dialog box, type 86400 in the Value data box, click Decimal in the Base option, and then click OK.Note According to the requirement of the computer that is running SQL server and the number of customization files, the value can be larger than 86400. The value of 86400 is equivalent to 24 hours.
  7. Right-click MSCRM, point to New, and then click DWORD Value to create a new DWORD value.
  8. Rename the DWORD value to the following value:
    ExtendedTimeout
  9. Right-click the DWORD value, and then click Modify.
  10. In the Edit DWORD Value dialog box, type 1000000 in the Value data box, and then click OK.Notes
    • In the Value data box, you can type a value that is larger than 1,000,000. However, do not type a value that is larger than 2,147,483,647. This is hexadecimal 0x7FFFFFFF.
    • If this key already exists, notice the current value. After you have completed the import or the upgrade for Microsoft Dynamics CRM, set the value of this key back to the original value or delete the key if it did not previously exist. The default OLEDB timeout value is 30 seconds.

After I reset IIS and I tried to export the solution again… and run all!!!