brad.orluk@nintex.com

Polling a users Exchange Online Out Of Office (OOF) status in using Nintex Workflow for Office 365

Blog Post created by brad.orluk@nintex.com Employee on Nov 22, 2015

So you've decided to automate a process in Office 365 with Nintex Workflow... excellent decision!

 

But, now that you're done building your workflow you notice when people are out the the office or 'OOF'  (Why is it OOF and not OOO? The Exchange Team @Microsoft explains) it breaks down. So, if you want something else to happen, like assign the task to another individual or kick off another workflow perhaps? Well then, I've got something that will be right up your alley!

 

By using a simple web service call, we can query the EWS (Exchange Web Services) of your Office 365 tenancy to find out if someone's OOF settings are enabled or not as well as the start and end dates for when they'll be out.

 

So first thing's first. We need to call the classic Exchange Online method (outlook.office365.com/EWS/Exchange.asmx) using the Web Request action. Keep in mind that the authorizing user needs to have the appropriate permissions* on the mailbox to perform this query.

Here is the body of the EWS call that you will need to use:

 

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/
"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema
"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"
>


   <soap:Body>
      <GetUserOofSettingsRequest xmlns="
http://schemas.microsoft.com/exchange/services/2006/messages
"
>


         <Mailbox xmlns="
http://schemas.microsoft.com/exchange/services/2006/types
"
>


            <Address>
EMAILADDRESSTOQUERY
@domain.onmicrosoft.com
</Address>

         </Mailbox>
      </GetUserOofSettingsRequest>
   </soap:Body>
</soap:Envelope>

 

*NOTE- You must have full control delegation of the mailbox you are querying enabled for the account that will be making the Web Request otherwise you will receive an 'Access Denied' error. Check out the following link on using PowerShell to delegate the mailbox to your service account: TechNet Exchange Online Cmdlets (Add-MailboxPermission)

 

The Exchange Online response will look something like this:

 

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/
"


  xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"


  xmlns:xsd="
http://www.w3.org/2001/XMLSchema
"
>


  <soap:Header>
  <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="685" MinorBuildNumber="8"
  xmlns:t="
http://schemas.microsoft.com/exchange/services/2006/types
"
/>


  </soap:Header>
  <soap:Body>
  <GetUserOofSettingsResponse xmlns="
http://schemas.microsoft.com/exchange/services/2006/messages
"
>


  <ResponseMessage ResponseClass="Success">
  <ResponseCode>NoError</ResponseCode>
  </ResponseMessage>
  <OofSettings xmlns="
http://schemas.microsoft.com/exchange/services/2006/types
"
>


  <OofState>Disabled</OofState>
  <ExternalAudience>All</ExternalAudience>
  <Duration>
  <StartTime>2006-11-03T23:00:00</StartTime>
  <EndTime>2006-11-04T23:00:00</EndTime>
  </Duration>
  <InternalReply>
  <Message>I am out of office. This is my internal reply.</Message>
  </InternalReply>
  <ExternalReply>
  <Message>I am out of office. This is my external reply.</Message>
  </ExternalReply>
  </OofSettings>
  <AllowExternalOof>All</AllowExternalOof>
  </GetUserOofSettingsResponse>
  </soap:Body>
</soap:Envelope>

 

So now you'll need to parse out (Xpath) the XML using the Query XML action to get the OofState and store it into a Collection variable. The node we're looking for is '//defaultNS:OofState'.

 

At this point I decided to leverage a Conditional Branch action to (if OOF is on) get the start and end dates and store them to variables using additional Query XML actions. I am not including their configuration as the workflow can be downloaded below. I could use this information to decide if I really want to not send the task to this individual (I would probably assign the task if they'll be in tomorrow but not if they're out for another two weeks).

 

 

In conclusion, using Nintex Workflow for Office 365 in conjuction with the API's available for various Microsoft cloud platforms can be a powerful combination for automating your various business processes!

 

The workflow that I built for this blog post is attached below:

Outcomes