web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Suggested answer
    riko4 Profile Picture
    5 on at
    RE: Append Values to Activity Party "To" Field using WebAPI Update & Javascript

    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.
  • riko4 Profile Picture
    5 on at
    RE: Append Values to Activity Party "To" Field using WebAPI Update & Javascript

    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.

  • meelamri Profile Picture
    13,216 User Group Leader on at
    RE: Append Values to Activity Party "To" Field using WebAPI Update & Javascript

    Hi,

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

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 394

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 123

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 122 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans