Dynamics 365 Plugins: Retrieve on Create Post-Operation event

Reminder: on the Post-Operation event pipeline of a Create event, you can’t retrieve the newly created entity using Retrieve() in the synchronous execution mode. I reckon this is because the database transaction will still be open in synchronous mode, so the record doesn’t yet exist in a way that Retrieve() can use. So, if you want to SYNCHRONOUSLY update the newly created entity in a plugin, and you need fields from the entity, you must get them from the passed entity in context.InputParameters[“Target”]. Otherwise, you must run the plugin in ASYNCHRONOUS mode.

Thanks to Anbelivebol-World for the post that reminded me of this.

BIDS editing CRM reports – Cannot connect to CRM 2016 Online

I downloaded a report from CRM 2016 Online to make some modifications in Visual Studio. On preview, I received the following error message:

An error occurred during local report processing.
An error has occurred during report processing.
Cannot create a connection to data source '[DATASOURCE]'.
The connection to server "https://[orgname].crm.dynamics.com/XRMServices/2011/Discovery.svc" could not be established.
Make sure that the connection string and credentials are correct, and try again.
Metadata contains a reference that cannot be resolved:
'https://[orgname].crm.dynamics.com/_common/error/errorhandler.aspx?BackURI=&ErrorCode=&Parm0=[Arabic text]: The service '/XRMServices/2011/Discovery.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'Microsoft.Crm.Site.Services, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..&RequestUri=/XRMServices/2011/Discovery.svc?wsdl&user_lcid=1025'.
CData elements not valid at top level of an XML document. Line 1, position 3.

I found the Arabic symbols in the metadata error particularly surprising! Naturally, the first thing I tried to do was Google the error message. (I cannot copy-paste the text from the preview window, so I retyped it here.) Unfortunately, none of the hodge-podge of barely related error details returned anything helpful.

The resolution was simple, if obscure: the connection string in the downloaded .rdl file was the same as the URL of the web client, e.g.


I retrieved the Organization Unique Name from CRM, under Settings > Customizations > Developer Resources. (older versions look like org901234ab, while newer ones appear to be based on the actual name such as ‘trellispoint’). Change the connection string to:

https://disco.crm.dynamics.com;[ORG UNIQUE NAME]

That’s it! The report should be previewable through Visual Studio.
EDIT: Even easier, use the API subdomain like so:


CRM Online can’t run custom reports (rsProcessingAborted)

Ever try to run a custom report in CRM Online and see the following error(s): Reporting Error The report cannot be displayed (rsProcessingAborted); or Invalid Argument:



In order to run FetchXML-based reports in CRM Online, the system user running the report must have the following security role permissions: Customization > Entity read, Customization > Field read. We’ve determined this by adding only those two permissions to a security role, and like magic, our custom reports started working!

There may be other considerations such as access to the entities in the reports, but if everything else appears to be configured correctly and/or working for administrators but not users, check those role permissions.

MSCRM Online can’t access entity at all

Yesterday, I noticed an entity seemed to be completely broken throughout my CRM online instance. I could not get to the list view or detail form for any Case. I was also unable to open any of the forms from the customizations view. I just kept getting the generic error: “An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization’s Microsoft Dynamics CRM Administrator. Finally you can contact Microsoft Support.”

I could not add new Cases through subgrids or quick-add either, and received the same error message, but this time with an option to download the error log. The log contains:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #AFE77CFEDetail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
 <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
 <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #AFE77CFE</Message>
 <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
 <Message>System.ArgumentNullException: Value cannot be null.
Parameter name: g</Message>
 <InnerFault i:nil="true" />
 <TraceText i:nil="true" />
 <TraceText i:nil="true" />

Finally found the solution here. It entails some editing of the XML for the entity in question.

  1. Create and export a solution containing the entity exhibiting the issue. Do not include dependencies.
  2. Extract the customizations.xml file from the resulting .zip file and open it for editing in the text editor of your choice.
  3. Search the text for the following text: “control id=”placeHolder_”. These are the invalid tags that are breaking everything!
  4. Carefully delete the containing <cell> tag for each occurrence. When complete, save the XML, replace the file in the solution .zip and re-import the edited solution.

This solved my issue and saved me the trouble of having to open a trouble ticket with Microsoft.

How to prevent textbox expanding horizontally in SSRS report

SSRS (a.k.a. SQL Server Tools) doesn’t show you the Intellisense for it, but regex is available in CRM online reports for string manipulation. (Here’s a full list of VB report functions available in CRM online.) The following expression will insert zero-length spaces (ChrW(8203)) between all characters in a string, so that a long string will always break if it runs out of space in a textbox, preventing your carefully-constructed tablix from getting wonky while still allowing the box to expand vertically.

I tried this with various versions of Split, Join, and ToString().ToCharArray() but was not getting the results I wanted. Array.ConvertAll is not available in the CRM Sandbox.

=System.Text.RegularExpressions.Regex.Replace(Iif(IsNothing(Fields!YourField.Value),"",Fields!YourField.Value), "(.)", "$1" & ChrW(8203).ToString())