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 CRM (Archived)

Created appointment with Optional(Optional Attendees)field Set the serviceappointment_activity_parties for Party List in Dynamics 365 using JavaScript ?

(0) ShareShare
ReportReport
Posted on by 894

Hi All,

I need help in setting party-list types for party list of field "Optional(Optional Attendees)" in Appointment Entity. As of now,we have datatypes : Contacts,account.

I used following code.

var parties = [];
var receiver1 = {};
receiver1["optionalattendees@odata.bind"] = "/contacts(" + customerID + ")";
parties.push(receiver1);
eEntity["serviceappointment_activity_parties"] = parties;


qry = GetWebAPIUrl() + entityName.toLowerCase() + "s";
var activityID = CreateRecord(qry, eEntity);

773411.Capture.PNG

I tried all methods for setting party-list types by default (unsupported way) - JavaScript.

I think my mistake this line.which field used for Optional Attendees field

receiver1["optionalattendees@odata.bind"] = "/contacts(" + customerID + ")";

Still unable to work on this party list with this field.

Can anyone help me to solve this problem ?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Try the below code-

    ==============

    var entity = {};
    entity.subject = "test appointment 2";
    entity.scheduledstart = new Date("08/10/2018 08:00:00").toISOString();
    entity.scheduledend = new Date("08/10/2018 08:30:00").toISOString();
    
    var parties = [];
    
    var requiredParty = {};
    requiredParty["partyid_account@odata.bind"] = "/accounts(ABC809D0-749C-E811-A965-000D3AE05E81)";
    requiredParty["participationtypemask"] = 5; //Required Attendees 
    
    var optionalParty = {};
    optionalParty["partyid_account@odata.bind"] = "/accounts(AFC809D0-749C-E811-A965-000D3AE05E81)";
    optionalParty["participationtypemask"] = 6; //optional Attendees 
    
    parties.push(requiredParty);
    parties.push(optionalParty);
    
    entity["appointment_activity_parties"] = parties;
    
    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/appointments", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 204) {
                var uri = this.getResponseHeader("OData-EntityId");
                var regExp = /\(([^)]+)\)/;
                var matches = regExp.exec(uri);
                var newEntityId = matches[1];
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send(JSON.stringify(entity));

    ===============

    Hope this helps

  • CRM Develope Profile Picture
    894 on at

    Thanks for your reply,Ravi Bhai. It's working fine..

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans