Search code examples
office-jsexchange-serveroutlook-addinexchangewebservices

What is the EWS SOAP XML code to get ICalUid?


We're using Office JS to develop an Addin for Outlook Calendar. For the same appointment, the EWS Ids of the Organizer and Attendees do not match. Apparently I need ICalUid from Exchange which is common across organizer and attendees and common across different events for the same Item, exactly what we need. But Office JS does not provide such property nor method to fetch it (only for .NET).

But Office JS provides Office.context.mailbox.makeEwsRequestAsync with which I can make SOAP requests to the Exchange server, using XML.

What is the EWS SOAP XML code to get ICalUid from EWS Id?

Does this work? Just replacing FieldURI with ICalUid?

function getSubjectRequest(id) {
   // Return a GetItem operation request for the subject of the specified item. 
   var result = 
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"' +
'               xmlns:xsd="https://www.w3.org/2001/XMLSchema"' +
'               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
'               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
'  <soap:Header>' +
'    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
'  </soap:Header>' +
'  <soap:Body>' +
'    <GetItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">' +
'      <ItemShape>' +
'        <t:BaseShape>IdOnly</t:BaseShape>' +
'        <t:AdditionalProperties>' +
'            <t:FieldURI FieldURI="item:ICalUid"/>' +
'        </t:AdditionalProperties>' +
'      </ItemShape>' +
'      <ItemIds><t:ItemId Id="' + id + '"/></ItemIds>' +
'    </GetItem>' +
'  </soap:Body>' +
'</soap:Envelope>';

   return result;
}

function sendRequest() {
   // Create a local variable that contains the mailbox.
   var mailbox = Office.context.mailbox;

   mailbox.makeEwsRequestAsync(getSubjectRequest(mailbox.item.itemId), callback);
}

function callback(asyncResult)  {
   var result = asyncResult.value;
   var context = asyncResult.context;

   // Process the returned response here.
}

Solution

  • For the IcalUid you would need

    <t:FieldURI FieldURI="calendar:UID"/>
    

    Keep in mind through the ICalUid isn't a searchable property so you won't be able to find Appointments based on this property if you need this then look at using the Extended Goid property like João linked in the comment.