I'm trying to register a plug-in to do some custom view creation, and I'm getting an error when opening the site after registering the Assembly and Steps. Here is the log of the error:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #108602C6Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>e072314e-303a-47f9-a95a-de4f3da9e54a</ActivityId>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #108602C6</Message>
<Timestamp>2018-02-20T19:44:04.3421711Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault>
<ActivityId>e072314e-303a-47f9-a95a-de4f3da9e54a</ActivityId>
<ErrorCode>-2147204719</ErrorCode>
<ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>Assembly should be provided</Message>
<Timestamp>2018-02-20T19:44:04.3421711Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>
[ActivitySubgridHelper: Cinteros.Crm.ActivitySubgridHelper]
[efa800d1-6b16-e811-80ef-00155d0a4712: Cinteros.Crm.ActivitySubgridHelper: RetrieveMultiple of activitypointer]
</TraceText>
</InnerFault>
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
I've been unable to get Profiling to work, or Trace Log messages to show up, due to CRM not loading the plug-in. Here is the code of the plug-in I'm trying to use:
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
namespace Cinteros.Crm
{
public class ActivitySubgridHelper : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
#if DEBUG
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
#endif
try
{
if (context.MessageName != "RetrieveMultiple" || context.Stage != 20 || context.Mode != 0 ||
!context.InputParameters.Contains("Query") || !(context.InputParameters["Query"] is QueryExpression))
{
tracer.Trace("Not expected context");
return;
}
var query = context.InputParameters["Query"] as QueryExpression;
#if DEBUG
var fetch1 = ((QueryExpressionToFetchXmlResponse)service.Execute(new QueryExpressionToFetchXmlRequest() { Query = query })).FetchXml;
tracer.Trace($"Query before:\n{fetch1}");
#endif
if (ReplaceRegardingCondition(query, tracer))
{
#if DEBUG
var fetch2 = ((QueryExpressionToFetchXmlResponse)service.Execute(new QueryExpressionToFetchXmlRequest() { Query = query })).FetchXml;
tracer.Trace($"Query after:\n{fetch2}");
#endif
context.InputParameters["Query"] = query;
}
}
catch (Exception e)
{
throw new InvalidPluginExecutionException(e.Message);
}
}
private static bool ReplaceRegardingCondition(QueryExpression query, ITracingService tracer)
{
if (query.EntityName != "activitypointer" || query.Criteria == null || query.Criteria.Conditions == null || query.Criteria.Conditions.Count < 2)
{
tracer.Trace("Not expected query");
return false;
}
ConditionExpression nullCondition = null;
ConditionExpression regardingCondition = null;
tracer.Trace("Checking criteria for expected conditions");
foreach (ConditionExpression cond in query.Criteria.Conditions)
{
if (cond.AttributeName == "activityid" && cond.Operator == ConditionOperator.Null)
{
tracer.Trace("Found triggering null condition");
nullCondition = cond;
}
else if (cond.AttributeName == "regardingobjectid" && cond.Operator == ConditionOperator.Equal && cond.Values.Count == 1 && cond.Values[0] is Guid)
{
tracer.Trace("Found condition for regardingobjectid");
regardingCondition = cond;
}
else
{
tracer.Trace($"Disregarding condition for {cond.AttributeName}");
}
}
if (nullCondition == null || regardingCondition == null)
{
tracer.Trace("Missing expected null condition or regardingobjectid condition");
return false;
}
var regardingId = (Guid)regardingCondition.Values[0];
tracer.Trace($"Found regarding id: {regardingId}");
tracer.Trace("Removing triggering conditions");
query.Criteria.Conditions.Remove(nullCondition);
query.Criteria.Conditions.Remove(regardingCondition);
tracer.Trace("Adding link-entity and condition for activity party");
var leActivityparty = query.AddLink("activityparty", "activityid", "activityid");
leActivityparty.LinkCriteria.AddCondition("partyid", ConditionOperator.Equal, regardingId);
return true;
}
}
}
I got the above from this page: community.dynamics.com/.../show-all-related-activities-in-a-subgrid
The error appears on the OOB Social Overview Dashboard, on the Activities records view, and any other views using the Activities views, EXCEPT for the one I'm trying to implement it into (which is Contact).
Can anyone see what might be causing this error, and how I can get the assembly to load properly so that I can profile the steps to see if it's doing what I need it to do?
Thank you.