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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Set "Organizer" field of Activity type entity issue using web api

(0) ShareShare
ReportReport
Posted on by 50

Hi,

I am creating a record of Appointment activity entity using web API. where I am setting the value of Organizer field. However, the record is creating without setting the organizer field. Below is my code.

var activityParties = [];
var party1 = {};
party1["partyid_systemuser@odata.bind"] = "/systemusers(" + Xrm.Page.Context.getUserId().replace("{", "").replace("}", "") + ")";
party1["participationtypemask"] = 7;   //for organizer
activityParties.push(party1);
parameters["appointment_activity_parties"] = activityParties;

The above object(parameter") passing to create records using web API.

I tried the same code for my custom activity entity and it is setting the value.

Please help me to set the organizer field using web api for acivity entity.

Thanks,

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    "Organizer" is not a lookup field, it's a partylist field which renders as a lookup field but it only represents a person or group associated with an activity.

    pastedimage1578642234463v1.png

    We need to craete a "activity parties" object and put the organizer data in it and then create the new record.

    function createAppointment(){
        //get systemuerid
        var id = Xrm.Page.context.getUserId();
        id=id.substring(1,id.length-1);
        //create activity parties object
        var parties = [];
        var organizer = {};
        organizer["partyid_systemuser@odata.bind"] = "/systemusers(" + id + ")";
        organizer["participationtypemask"] = 7//organizer
        parties.push(organizer);

        var data={
            "subject":"associatedTest",
            "appointment_activity_parties":parties,
            "scheduledstart":new Date(),
            "scheduledend":new Date()
        };
        Xrm.WebApi.createRecord("appointment"data).then(
            function success(result) {
                console.log("appointment created with ID: " + result.id);
                // perform operations on record creation
            },
            function (error) {
                console.log(error.message);
                // handle error conditions
            }
        );
    }

    And the "participationtypemask" should be "7" as organizer, you could find the list here.

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/activityparty-entity

    pastedimage1578645001040v2.png

    And we could see that I created an appointment named "assoicatedTest" successfully.

    pastedimage1578645570444v3.png

    About more information for ActivityParty, you could refer to the following links.

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/activityparty-entity

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/activityparty?view=dynamics-ce-odata-9

    Hope it helps.

    Best Regards,

    Leo

  • PM3 Profile Picture
    50 on at

    Thanks,

    I am able to set the organizer field using below link:

    community.dynamics.com/.../regarding-field-does-not-populate-in-uci-using-xrm-navigation-openform-client-api

    However, I am facing issue while creating service activity records using web api. I am getting error code 400. I ensure all parameters are correct which I am passing to create records using web api reques as below:

    $.ajax({

                       type: "POST",

                       url: url,

                       contentType: "application/json;charset=utf-8",

                       beforeSend: function (xhr) {

                           xhr.setRequestHeader("Accept", "application/json");

                           xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

                           xhr.setRequestHeader("OData-MaxVersion", "4.0");

                           xhr.setRequestHeader("OData-Version", "4.0");

                           xhr.setRequestHeader("Prefer", "return=representation");

                       },

                       dataType: "json",

                       data: jsonEntity,

                       success: function (data, textStatus, xhr) {                        

                               successCallback(id, record, inNotes);                                  

                       },

                       error: function (error) {

                           errorCallback();

                       }

                   });

    Please help me to understand the error.

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Please check your url format like single quotes. And where did you call this api? In D365 or outside D365?

    You could get some details from the error 400 response in browser development tool(F12).

    And if you are using D365 V9.X, you could try the "Xrm.webapi" I showed before, it is more convenient.

    Best Regards,

    Leo

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 144 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 59

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans