Tag Archives: C#

K2 Exchange OOFSettings

I’ve just posted K2 Exchange OOFSettings service broker at K2 Community site. This broker uses the EWS Managed API to access the Out-of-Office information on the Exchange server.

Where to get the broker?

The broker can be downloaded from:

Limitations of the K2 Exchange OOFSettings broker

This is the list of limitations of this broker:

  • Since the EWS API requires the user’s login name and password to execute the web service, the broker needs to run under SSO authentication mode. The selected authentication mode must be an AD security provider.
  • The email address will be retrieved via the System.DirectoryService.AccountManagement API, so make sure the user has a valid email address in AD.
  • When UseAutoDiscover service key is set to true, the broker will make use of the user’s email address to auto discover the Exchange server’s URL. See the following link on how to configure auto discover service for Exchange. https://technet.microsoft.com/en-SG/library/bb201695(v=exchg.141).aspx.

Service Instance Setup

As the broker requires the user’s login name and password to execute the EWS call, the service instance must be set up to use SSO Authentication Method and and AD security provider (by default, K2) must be selected.

SSO Authentication Mode
SSO Authentication Mode

The following are the description for the service keys:

Service Keys
Service Keys
  • UseAutoDiscover – Whether to lookup the URL using the Auto Discover service.
  • RequireHTTPS – Whether to enforce that the Exchange server’s URL needs to use the HTTPS scheme.
  • EwsURLFallback – The Exchange server’s EWS URL to be used when the broker fails to get a valid response from the Auto Discover service or when the UseAutoDiscover key is set to false.

Available Methods in K2 Exchange OOFSettings broker

This is the list of methods available:

Get OOF Settings

This method grabs the current selected user’s out of office settings from the Exchange server.

K2 Exchange OOFSettings - Get OOF Settings method
Get OOF Settings method

Turn On OOF Notification with Schedule

This method allows the user to turn on the out of office notification, set the reply email content and most importantly set the start and end date/time.

K2 Exchange OOFSettings - Turn On OOF Notification with Schedule
Turn On OOF Notification with Schedule

Turn On OOF Notification Permanently

Well, this method is the same as the previous one, except that there is no start and end date/time defined. It will be turned on as long as required.

K2 Exchange OOFSettings - Turn On OOF Notification Pernament
Turn On OOF Notification Permanent

Turn Off OOF Notification

This method will turn off the out of office notification.

K2 Exchange OOFSettings - Turn Off OOF Notification
Turn Off OOF Notification


Have Fun!

K2 smartforms control custom property

In this article, I’m going to show you how to add a property, MaxFileSize, to a K2 smartforms custom control.

Note: The focus of this article is all about adding a property and using it in your control. For the basics on how to create a K2 smartforms control, please visit K2 smartforms Developers Reference .

Adding a K2 smartforms control custom property

1. Add a new property to your control’s xml definition

In your control’s definition xml file, add a new Prop element under Properties. It should look like the following:

ID attribute is the new property’s name and InitialValue sets the default value when the control is first added to a View.

For more information about what each of the property’s attribute does, look at Control Definition XML File.

2. Add a Getter/Setter method in your control class to access the property value

You need this method to create and save the option values into the control so that you can retrieve it in your JavaScript later.

The method name should match the ID value set in the property earlier on. In the GetOption and SetOption method, use small caps for your option name (e.g. maxfilesize) as this will be the data-options attribute registered in the control’s html.

3. Reading the option values via JavaScript

Now, as I mentioned earlier, the options will be surfaced as data-options attributes in the control’s html. Use your browser’s in-built developer tools to look at the control’s html. It should look similar to this:

Notice that the maxfilesize value has been registered in the data-options attribute? This is the value set in the K2 Designer and you have access to it now. =)

So, last step. To get the value, just use the jQuery .data function to retrieve the data-options values. For me, I create a initialise function to handle the values initialization.


Good luck!