Skip to main content

Notifications

Announcements

No record found.

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 884

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

  • CRM Develope Profile Picture
    CRM Develope 884 on at
    RE: Created appointment with Optional(Optional Attendees)field Set the serviceappointment_activity_parties for Party List in Dynamics 365 using JavaScript ?

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

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Created appointment with Optional(Optional Attendees)field Set the serviceappointment_activity_parties for Party List in Dynamics 365 using JavaScript ?

    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

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans