As a CRM administrator, you may come across the following error in your CRM Event Logs:
“Query execution time of XX seconds exceeded the threshold of 10 seconds”

This is said to merely be informational. If you’d like to see the setting in your CRM’s SQL database, run the following script against your CRM’s database:

SELECT IntColumn FROM MSCRM_CONFIG..ServerSettingsProperties WHERE ColumnName='LongQueryThresholdInSeconds'

It should return the value you had seen in the warning. To lengthen the timeout to stop the error, you can run the following script against your database:

UPDATE MSCRM_CONFIG..ServerSettingsProperties SET IntColumn = '20' WHERE ColumnName='LongQueryThresholdInSeconds'

We had a need to send custom workflow emails that included all attachments from the Notes section of Opportunities in Dynamics CRM 2015. This is not an out of the box functionality. It requires the development of a plugin that must be registered in CRM to achieve the desired results. I’ll try to be thorough in my explanation, because I know it can be tough to put together the bits of information that you will find on this topic if you’re just starting out developing for CRM.

It is important that I note here that I obtained most of the information needed to create this from this article. It was written for doing similar functionality for a single attachment in the Accounts entity, but I needed a way to get every attachment from the Opportunity entity. One of the commenters posted what they had done unsuccessfully in the comments section and I merely combined the code from the two people and made a working Opportunity plugin that includes all attachments – instead of only the first one. You’ll notice that I didn’t even bother fixing the spelling error on “attachement”. Feel free to do so in your own project.

  • You’ll need the Dynamics CRM 2015 Software Development Kit. You can download it here. Without this, you won’t have the required DLLs for adding as references to your project in Visual Studio and you won’t have the plugin registration tool (SDK folder\SDK\Tools\PluginRegistration).
  • You will also need Visual Studio, obviously.
  • You may also need to install .NET Framework 4.5.2, if you haven’t already.
  1. Create a new project in Visual Studio. The settings should look like the following:
  2. Step1

  3. Rename the class file to SendEmailWithAttachement.cs to match the file.
  4. Right click on your project name (EmailAttachment), below your solution name in the Solution Explorer, click Properties. Click on the Signing tab. Check the box to Sign the assembly. If you don’t do this, you’ll get errors when you try to register your plugin with CRM. You don’t need a password, so make sure you clear that box. It should look like below:
  5. step2

  6. You’ll need to right click on References in the Solution Explorer and Add Reference a few times. Some will be part of Assemblies Framework and other you need to browse and obtain from the SDK. Be sure you have similar to the following screenshot when you are done:
  7. step3

  8. Now you’ll want to click on the SendEmailWithAttachement.cs class file to open it. Paste the following code in to it:
  9. using System;
    using System.Linq;
    using System.Activities;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Workflow;
    using Microsoft.Xrm.Sdk.Query;
    using Microsoft.Crm.Sdk.Messages;

    namespace EmailAttachment
    public class SendEmailWithAttachement : CodeActivity

    //define output variable
    public InArgument SourceEmail { get; set; }

    protected override void Execute(CodeActivityContext executionContext)
    // Get workflow context
    IWorkflowContext context = executionContext.GetExtension();
    //Create service factory
    IOrganizationServiceFactory serviceFactory = executionContext.GetExtension();
    // Create Organization service
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
    // Get the target entity from the context
    Entity OpportunitiesID = (Entity)service.Retrieve("opportunity", context.PrimaryEntityId, new ColumnSet(new string[] { "opportunityid" }));

    AddAttachmentToEmailRecord(service, OpportunitiesID.Id, SourceEmail.Get(executionContext));

    private void AddAttachmentToEmailRecord(IOrganizationService service, Guid OpportunitiesID, EntityReference SourceEmailID)
    //create email object
    Entity _ResultEntity = service.Retrieve("email", SourceEmailID.Id, new ColumnSet(true));
    QueryExpression _QueryNotes = new QueryExpression("annotation");
    _QueryNotes.ColumnSet = new ColumnSet(new string[] { "subject", "mimetype","filename","documentbody" });
    _QueryNotes.Criteria = new FilterExpression();
    _QueryNotes.Criteria.FilterOperator = LogicalOperator.And;
    _QueryNotes.Criteria.AddCondition(new ConditionExpression("objectid", ConditionOperator.Equal, OpportunitiesID));

    EntityCollection _MimeCollection = service.RetrieveMultiple(_QueryNotes);

    if (_MimeCollection.Entities.Count > 0)
    for (int i = 0; i < _MimeCollection.Entities.Count; i++) { //we need to fetch first attachment Entity _NotesAttachment = _MimeCollection.Entities[i]; //Create email attachment Entity _EmailAttachment = new Entity("activitymimeattachment"); if (_NotesAttachment.Contains("subject")) _EmailAttachment["subject"] = _NotesAttachment.GetAttributeValue("subject");
    _EmailAttachment["objectid"] = new EntityReference("email", _ResultEntity.Id);
    _EmailAttachment["objecttypecode"] = "email";
    if (_NotesAttachment.Contains("filename"))
    _EmailAttachment["filename"] = _NotesAttachment.GetAttributeValue("filename");
    if (_NotesAttachment.Contains("documentbody"))
    _EmailAttachment["body"] = _NotesAttachment.GetAttributeValue("documentbody");
    if (_NotesAttachment.Contains("mimetype"))
    _EmailAttachment["mimetype"] = _NotesAttachment.GetAttributeValue("mimetype");

    SendEmailRequest SendEmail = new SendEmailRequest();
    SendEmail.EmailId = _ResultEntity.Id;
    SendEmail.TrackingToken = "";
    SendEmail.IssueSend = true;
    SendEmailResponse res = (SendEmailResponse)service.Execute(SendEmail);



    At this point, if you have any underlines or errors showing in the code, you are likely missing a reference.

  10. Build your plugin at this point by clicking on Build – Build Solution. If it builds correctly and you have no errors, you should be ready to register your plugin in CRM.
  11. Inside of the SDK folder that you unzipped, open SDK\Tools\PluginRegistration. Run the PluginRegistration.exe file to open the tool.
  12. Click on the Create New Connection button. If you’ve never run the registration tool, you’ll need to enter your local settings. Select On-premises. Enter the Server name. If you use SSL, make the port 443 and check the box to Use SSL. You’ll probably want Authentication Source to be Active Directory and then enter your user and Domain information. Click on the Login button. If all is correct, the system should login and provide you with the registration tools.
  13. Click on the Register button then on Register New Assembly.
  14. In the Register New Assembly window, use the browse button to locate and select your newly built DLL file. It should look like the following:
  15. step4

  16. Click on the Register Selected Plugins button. If all goes well, you’ll now see the new plugin in the list of Registered Plugins & Custom Workflow Activities. You can close out of the registration tool at this point.
  17. All that is left is to open CRM and build your new workflow.

  18. Go to Settings – Processes. Click the New button to start a new workflow. Give it a name, set Category to Workflow and select Opportunity for the Entity. Be sure that New blank process is selected and click the OK button. It should look similar to below:
  19. step5

  20. At this point, just create a condition that is needed by your workflow. Add steps to process when meeting those conditions. I’ll skip over this as everyone’s will differ, but I will point out that to make this work, you want to Add Step, select Create Record and then select Email for the Create dropdown list.
  21. Click on the Set Properties button and enter the information in to your email form that you wish to send.
  22. Click on Add Step and select CRM_NoteAttachments ( and then EmailAttachment.SendEmailWithAttachement or whatever your name was for your plugin. Mine is shown below:
  23. step6

  24. Click on Set Properties and configure like the following:
  25. step7

  26. Click on Save and Close and then you’ll have your basic workflow, ready for activation and testing. Here is the final view of a test workflow:
  27. step8

    Hopefully, this will fill enough gaps in the process for you to figure out the process for this. It took a lot of reading for me to get this working properly, using multiple forum threads. I just wanted to lay it out from beginning to end so that it saves someone else some time. Please check out the thread that I got most of the code from as well. That person deserves a lot of credit for his work.

One of the things that is not very intuitive about CRM 2015 is how to create a dependent option set. There are many articles on the topic for CRM 2011 and 2013, but not many specific to CRM 2015 at this time. Not much has changed, but most articles you find won’t give you all the steps it takes to understand the process. For example, many articles won’t bring up the need for the Software Development Kit – which provides you with the example JavaScript code for this task.

The following article is what I found to be a great example of the process of creating a dependent option set and it works in CRM 2015:

I won’t rewrite that article for 2015. What I want to point out is that you’ll need to tweak this process if you require a dependent option set in more than one form type. For example, if you need a different dependent option set in your Account and Opportunity forms, you cannot share both option sets within the same XML file. It kind of works, but you’ll be plagued by “Error on the page” messages in your browser with every refresh – referencing null values and line 68 of your JavaScript file.

In order to make this work (error free), you’ll need to create an XML file with just the appropriate dependent option sets to each form type. The one exception seems to be if you’re using the exact same option sets between forms, using the same values. Inside of you Form Properties for each form, you’ll simple set the appropriate XML file that you have registered. I have an XML file for Opportunities and also one for Accounts.

Hopefully this will save people time when they come upon the issue. The errors occur at the form level of page load, without even accessing the option sets for selection.

In our old Microsoft Dynamics CRM 4 system, date formatting was done on the back-end, by utilizing workflows and added custom DLLs. This caused a lot of extra workflow rules to screen people by location, in order to ensure that European employees see proper date formatting.

In Microsoft CRM 2015, everyone will be able to set their own date options easily. This translates to how users see dates on Opportunities, Contacts, Accounts, and even the emails they receive from the system.

To set your date options, click on the gear icon in the upper right corner and click Options.


In the Options window, click on the Formats tab and select the date formatting you would prefer. Click OK to store your selection.


One of the scenarios that I ran in to with configuring Microsoft CRM 2015 is changing then DNS and URL of the site. When I installed and configured it, I didn’t have a final idea planned for a URL. Development started to figure out if I could jump versions from Dynamics 4 all the way to CRM 2105 by rebuilding the needed fields and workflows, export the data from the old system and import desired data back in to the new system. I found that the process worked well for skipping the other versions, but I was further along than I wanted to be to restart. If I could change the information, I could save hours of reproduction. There wasn’t a lot of 2015 information available on this topic, but the process was possible in versions 2011/2013. Using that information ended up working well. You can see an example here

Step 1:
– Update the DNS entry that points to the server IP address. This may need to be done by your Infrastructure team.

Step 2:
– Update your IIS bindings for the site to utilize the new URL

  • Open IIS Manager and select the existing Microsoft Dynamics CRM site
  • Click the Bindings link in the Action Panel on the right
  • Select the binding to modify and click on Edit
  • Modify the host name and port to reflect the new values
  • Close the IIS Manager

Step 3:
– Update the ServerURL registry entry with the new URL you want to use.

  • Open Regedit and browse the folders to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM
  • Update the ServerURL value to your newly desired URL
  • Close the registry editor.

Step 4:
– Modify the settings for CRM from within the Microsoft Dynamics CRM Deployment Manager

  • Open Microsoft Dynamics CRM Deployment Manager
  • Right click on Microsoft Dynamics CRM at the top of the left pane and click Properties
  • Select the Web Address tab and modify the addresses shown to reflect your new URL
  • If you’re configuring for SSL, be sure to select HTTPS. Be sure that your certificate was selected and HTTPS is configured in Step 2.
  • Click OK to close the window and then close out of Deployment Manager.

Step 5:
– Restart the Microsoft Dynamics CRM Asynchronous Processing Service (or just restart the server). I had to restart the server, because I was generating a Generic Error on the homepage.

Step 6:
– You may require additional registry changes if they don’t exist. You may want to disable loopback on the server.

  • Open Regedit and browse the folders to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  • Right-click Lsa, click on New, and then click DWORD Value.
  • Type DisableLoopbackCheck, and then press ENTER. Right-click DisableLoopbackCheck, and then click Modify. In the Value data box, type 1, and then click OK.
  • Close the registry editor and restart the server.
  • These steps should get CRM 2015 working on the new URL, using the new DNS name. If you run in to issues, try searching on the same issue in 2011/2013 versions and you can find more details on the steps required. A good many of the server solutions for 2011/2013 versions are also appropriate for 2015.

Recently, I ran in to an issue where SharePoint would error out when trying to save a page edit. Even if you just went to edit mode and clicked to save and close, it would error out and provide a correlation ID without having made a change.

Using ULS Viewer, I took a look at the correlation ID to find that the error was, “The SPListItem provided is not compatible with a Publishing Page.” This was a new error to me, so I started looking for more information. Googling it, I found several references and explanations on what needed to be done, but not many sources really explained the process of fixing it clearly.

To fix this issue, you need to disable and re-enable the Publishing service for SharePoint, using Powershell. Open Powershell on the SharePoint server as an administrator. Type the following commands:

Disable-SPFeature –Identity Publishing –url http://Site_Name_Here

Wait for the process to complete successfully, then re-enable it:

Enable-SPFeature –Identity Publishing –url http://Site_Name_Here

Assuming the process completes successfully, you should be able to edit and check-in the page again without any problems. It is unclear to me what causes this issue, but at least it’s an easy fix.

We recently downgraded SQL Server versions from Enterprise to Standard, due to Microsoft changing their licensing rules. We were not using any features of Enterprise, so we moved from SQL 2012 Enterprise to SQL 2012 Standard. There are many knowledge-base articles available by Google search on how to accomplish this downgrade.

What you might not know, is that SharePoint may be using the data compression feature of SQL Enterprise without you knowing. SharePoint 2010 tends to use data compression, if able, for Web Analytics and the Search Service Application Store. If you don’t know this ahead of time, you will notice when SharePoint searches break.

After a downgrade of SQL from Enterprise to Standard, your affected databases will be inaccessible within SSMS. If you know the location of the database, you will need to copy the .MDF and .LDF files for the Search_Service_Application_PropertyStoreDB_[GUID HERE] database to an Enterprise installation to run queries on it and disable compression for the affected tables. Alternatively, you can remove your search service and reconfigure it. There are many articles on doing this available upon Google search.

To fix the Web Analytics Service, the only fix I found was to remove the functionality in Central Administration and set it up from scratch. I was not able to fix it the same way as the Search Service to maintain existing information.

Sometimes, it’s necessary to copy hundreds of files to a picture library in SharePoint. SharePoint 2007 had an easy way to do this in Explorer view. The feature still exists in SharePoint 2010, but it is accessed in a slightly different manor.

From within the picture library, click on Actions – Open with Windows Explorer. When the window opens, you cand rag and drop as many files as needed, without the worry of the 100 file limit.


I came across an old ASP.NET website that I had to make some adjustments to for a new feature. A portion of the changes were adding required field validators to a new form. The validators seemed to work normally, until I noticed that I was getting postbacks even when validation failed.

I thought that somehow my submission button had its CausesValidation=”False”, but it was correctly set. I checked all of my validators and they were all looking at the proper controls, so I was confused as to what would cause this behavior.

It turns out that when you upgrade old pages that were originally written in older versions of .NET (such as 1.1), to newer versions like 3.5 or 4.0, Visual Studio will add a line to your web.config file like this:
xhtmlConformance mode="Legacy"

You must delete or comment out that line for the validation to function properly.

We came across a problem with SharePoint 2010 recently. We had just setup a new MySite configuration, to move our personal sites out in to their own database and application. Everything was working fine for some time.

I noticed the following error in the event logs later on:

Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unneccesary system resources.
To configure the account use the following command ‘stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl’. The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account.
Additional Data:
Current default super user account: SHAREPOINT\system

I set the standard accounts for User and Reader that we had in Active Directory through PowerShell, by doing the following:

$w = Get-SPWebApplication “http:///”
$w.Properties[“portalsuperuseraccount”] = “domain\superuser”
$w.Properties[“portalsuperreaderaccount”] = “domain\superreader”

Note: If using claims authentication, you will need to specify the accounts differently by adding: i:0#.w| in front of the account (for example: i:0#.w|domain\superuser).

Everything worked for my own site, so I hadn’t noticed any issues until users started reporting Access Denied errors trying to reach their sites.

The problem ended up being that these accounts were not already in the User Policy for the newly created application, as they were assigned in the previous applications. In order to fix this, we had to do the following:

– Go to: Application Management – Manage Web Applications – Select ‘Your Application Name Here’
– Click on User Policy on the top ribbon bar
– In the resulting window, add the accounts you have in Active Directory for domain\superuser (with Full Control) and domain\superreader (with Full Read)

It is important to note that this can happen in any application that you setup the object cache. Hopefully this will help someone else resolve their issues.