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.