Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

The 'Retrieve' method does not support entities of type 'activityparty'. #332

Open
d4hines opened this issue Aug 8, 2018 · 3 comments
Open

Comments

@d4hines
Copy link

d4hines commented Aug 8, 2018

Hello all,
I've got code that is passing tests perfectly locally using fake-xrm-easy, but failing when running in the CRM.

Here's the error message:

Plugin Trace:

[Microsoft.Xrm.Sdk.Workflow: Microsoft.Xrm.Sdk.Workflow.Activities.RetrieveEntity]
[RetrieveEntity]



Error Message:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The 'Retrieve' method does not support entities of type 'activityparty'.Detail: 
<OrganizationServiceFault xmlns:i="http:https://www.w3.org/2001/XMLSchema-instance" xmlns="http:https://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147219456</ErrorCode>
  <ErrorDetails xmlns:d2p1="http:https://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>The 'Retrieve' method does not support entities of type 'activityparty'.</Message>
  <Timestamp>2018-08-08T16:01:19.1878484Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>[Microsoft.Xrm.Sdk.Workflow: Microsoft.Xrm.Sdk.Workflow.Activities.RetrieveEntity]
[RetrieveEntity]
</TraceText>
</OrganizationServiceFault>
   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Retrieve(EntityReference entityReference, ColumnSet columnSet, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode)
   at Microsoft.Crm.Extensibility.InprocessServiceProxy.RetrieveCore(String entityName, Guid id, ColumnSet columnSet)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Retrieve(String entityName, Guid id, ColumnSet columnSet)
   at Microsoft.Crm.Workflow.Services.RetrieveActivityService.<>c__DisplayClass1.<RetrieveInternal>b__0(IOrganizationService sdkService)
   at Microsoft.Crm.Workflow.Services.ActivityServiceBase.ExecuteInTransactedContext(ActivityDelegate activityDelegate)
   at Microsoft.Crm.Workflow.Services.RetrieveActivityService.RetrieveInternal(String entityName, Guid entityId, String[] attributes)
   at Microsoft.Crm.Workflow.Services.RetrieveActivityService.ExecuteInternal(ActivityContext executionContext, RetrieveEntity retrieveEntity)
   at Microsoft.Crm.Workflow.Services.RetrieveActivityService.Execute(ActivityContext executionContext, RetrieveEntity retrieveEntity)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I'm not sure what would be involved in patching this, but it would have been nice to get this error message locally as well as on the server.

Also, does anyone know a workaround for this? I don't understand why I can't retrieve a particular entity, so I'm not really sure how to proceed.

Thanks a ton!

@jordimontana82
Copy link
Owner

Hi Daniel,

Thanks for raising this issue... indeed, if CRM is giving that error we should then introduce the same in FakeXrmEasy.

ActivityParty is meant to be used as an intersect entity between the activity (email, phonecall, etc) and the recipients so maybe it's forcing to retrieve entity records against the activity entity first (just guessing here... I've personally never had to query activity party records directly..)

@d4hines
Copy link
Author

d4hines commented Aug 10, 2018

Hi Jordi,
Thanks for the response. After some further experimentation today, it seems that there were two critical factors, One was the ReferenceTarget attribute on the OutArgument. It seems that a workflow activity cannot return an ActivityParty as an output, so I had to change:

[Output("Party Entity Reference")]
[ReferenceTarget("contact")]
public OutArgument<EntityReference> ReferencedEntity { get; set; }

to

[Output("Party Entity Reference")]
[ReferenceTarget("contact")]
public OutArgument<EntityReference> ReferencedEntity { get; set; }

The second issue was I also had to remove any direct retrievals of the ActivityParty entity.

For anyone struggling to query the ActivityParties, the only way to access was it was:

phonecall.GetAttributeValue<EntityCollection>(prop)?.Entities.FirstOrDefault();

where prop is the
name of the attribute referencing the activity party (e.g. "to", "from", etc.)

@jordimontana82
Copy link
Owner

Thx for the update Daniel, so maybe I'll leave this a new feature, i.e. Raise an exception whenever a retrieve is made against the activity party entity directly. It would be nice to raise an exception if someones tries to return an activity party as an OutArgument too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants