Announcements
Hi all
Can anyone point me to some decent resource on how to add or remove parties from an existing ActivityParties collection?
So far I've managed to read the existing collection from CRM, but if I simply add another party to that array and try PATCH, I get "CRM do not support direct update of Entity Reference properties, Use Navigation properties instead". If I create a new collection/array with just my new party in to and PATCH, it overwrites the existing collection with my new one. Now I'm looking into rebuilding the collection, but the returned collection doesn't have an indication of which entity the party is coming from, so I can't rebuild the odata binding?
Any help or pointers would be appreciated?
Thanks
James
*This post is locked for comments
Hi,
You just need to get the existing partylist and store it first in a variable(array) this will contain an array of objects. Once you get that you can then push the new parties(as object) in your variable array. Then update the partylist field with this variable.
See these links for sample
rajeevpentyala.com/.../get-and-set-partylist-fields-using-jscript
community.dynamics.com/.../160583
Regards,
Macoy
This is what I'm posting to api/data/v9.0/activityparties
{"activityid_activitypointer@odata.bind": "/activitypointers(898e208c-d786-e911-b811-005056990ea4)", "partyid_account@odata.bind": "/accounts(dd487ae7-c66d-e911-b80e-005056990ea4)","participationtypemask": 4}
Which results in:
"error": {
"code": "0x80040800",
"message": "The 'Create' method does not support entities of type 'activityparty'.",
"innererror": {
"message": "The 'Create' method does not support entities of type 'activityparty'.",
"type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]",
"stacktrace": " at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.CreateInternal(Entity entity, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Dictionary`2 optionalParameters)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.CreateOrganizationResponse(Entity entity)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject)\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
Did you ever figure this out? There's plenty of examples using the SDK or adding parties with the activity but I'm trying to figure out what JSON to send to add parties to an existing activity.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator