Setting email to “Pending Send” doesn’t work – Dynamics 365

Couldn’t get an email generated by a workflow to send using the “classic” method of changing the status to “Pending Send”. The email would just sit there in Pending Send status forever with an alert message that said “This message has not yet been submitted for delivery,” along with a non-helpful suggestion to see help.

Turns out, this method of triggering an email to send doesn’t work anymore (as of 2015 update 1). It took me a while to tweak my google-fu to locate this page, but it certainly confirmed my suspicions.

I simplified the code from that page even further below. PLEASE NOTE, I’m only using this to send notifications from workflows, so tracking tokens in the subject line are not generated. If you need to use this with tracking tokens, use the code from the original link.

using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Crm.Sdk.Messages;

public class SendEmail : CodeActivity
    [Input("Email to send")]
    public InArgument<EntityReference> Email { get; set; }

    protected override void Execute(CodeActivityContext ec)
        var context = ec.GetExtension<IWorkflowContext>();
        var factory = ec.GetExtension<IOrganizationServiceFactory>();
        var service = factory.CreateOrganizationService(context.UserId);

        var email = Email.Get(ec);
        var req = new SendEmailRequest() { EmailId = email.Id, IssueSend = true };

Maybe Microsoft will change this in a future update, but for now it looks like you’re stuck needing a custom workflow plug-in for your deployment.


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 &quot;https://[orgname]; 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];ErrorCode=&amp;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..&amp;RequestUri=/XRMServices/2011/Discovery.svc?wsdl&amp;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:;[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="" xmlns="">
 <ErrorDetails xmlns:d2p1="" />
 <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #AFE77CFE</Message>
 <ErrorDetails xmlns:d3p1="" />
 <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.