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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Append Values to Activity Party "To" Field using WebAPI Update & Javascript

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I am currently working on a custom activity entity where I have to update the "To" field - dynamically adds up with user records as recipients, via PCF Control.

Here is my code:

//this will get the activity entity and the multi-table/lookup or polymorphic lookup "To" field (activity_parties)

//once retrieved, create new partylist then push to add it to the existing activity partylist

then update

context.webAPI.retrieveMultipleRecords("entityName", "?$expand=entityName_activity_parties($select=participationtypemask)&$filter=_regardingobjectid_value eq " + this._currentEntity.id).then(
(result) => {
for (var i = 0; i < result.entities.length; i++) {
var activityid = result.entities[i]["activityid"];
var activity_parties = result.entities[i]["entityName_activity_parties"];
}
var updateData: { [key: string]: any } = {};
let newPartyList: any;

newPartyList = {
"participationtypemask": 2,
"partyid_systemuser@odata.bind": "/systemusers(" + userid + ")"
}
activity_parties.push(newPartyList);
updateData = {
"entityName_activity_parties": activity_parties,
}
this._context.webAPI.updateRecord(entityName, activityid, updateData);

*newPartyList was pushed to existing activity_parties (thru debugging) but as I checked the To field, no values has been added. 

I found some links with the same scenario using Xrm.Page.getAttribute("to").setValue(partlistData); --which is not applicable to my code/web api call or is there something I am missing?

https://powerobjects.com/development/populate-crm-2011-lookup-partylist-field-javascript/

https://rajeevpentyala.com/2012/04/02/get-and-set-partylist-fields-using-jscript/

Thank you.

I have the same question (0)
  • meelamri Profile Picture
    13,218 User Group Leader on at

    Hi,

    Can you please share your logs ? I would like to see the value of the activity_parties list in more detail...

  • riko4 Profile Picture
    5 on at

    Hi Mehdi,

    Please see below for details:

    activity_parties: Array(4)
    0:
    @odata.etag: "W/\"139728979\""
    activitypartyid: "16579059-4657-ec11-8f8f-00224840a19b"
    participationtypemask: 1
    participationtypemask@OData.Community.Display.V1.FormattedValue: "Sender"
    _activityid_value: "aaca22b0-0e57-ec11-8f8f-00224840a19b"
    _activityid_value@Microsoft.Dynamics.CRM.associatednavigationproperty: "activityid_activitypointer"
    _activityid_value@Microsoft.Dynamics.CRM.lookuplogicalname: "activitypointer"

    pastedimage1639052789948v1.png

    Thank you.

  • Suggested answer
    riko4 Profile Picture
    5 on at

    Hi,

    Just an update to this post.

    I finally get this working using

    webAPI.retrieveMultipleRecords("activityparty", "?$select=participationtypemask,_partyid_value&$filter=_activityid_value eq " + entityId).
    To retreive the current activity parties then store the objects with participationtypemask = 1 (From) and 2 (To) to an array.
    I now then push the new parties to the same array then update the entity record.
    These are the helpful links I also found:
    Please let me know if there is a better way.
    Thank you.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 126

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 71 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans