web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Correct way to update (add or remove) the parties in ActivityParties against an activity (like PhoneCall) using JavaScript and WebApi?

(0) ShareShare
ReportReport
Posted on by 2

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

I have the same question (0)
  • NeilN Profile Picture
    40 on at

    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.

  • NeilN Profile Picture
    40 on at

    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()"
            }

  • Suggested answer
    Macoy Profile Picture
    275 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans