Tuesday, September 30, 2014

The nuts and bolts of Lync / Presence / IM integration

I recently had to figure out what makes the "Presence" integration tick. I didn't find any really good explanations to work from, so here I'll try sum up the bits that makes this work. I'll try to boil the information down to the bare minimum of what you need to know. The feature is actually very flexible and I don't want this to be a very long post with information about tons of ways to use it.

Okay, first of all you'll need to have a Lync client installed along with your AX client. And you need to be logged into Lync with your account for that.

Next you'll need to add some contacts in AX. You must create an address of type e-mail and fill the address with the e-mail address this contact uses for instant messaging (IM). Please observe that some people have different e-mail addresses for regular e-mail and for IM.

In the contact form you must click the More options / Advanced button and check the "Instant messenger sign-in" check box. This tells AX to use this particular address of the contact when integrating with Lync. If the address is only used for IM and not also for regular e-mail, check the "Instant message" check box too.

When you want to show the presence indicator next to a field on a form, there are three properties of the form field to consider:
  • PresenceIndicatorAllowed. I assume you can guess what this controls.
  • PresenceDataSource and PresenceDataField. This is the datasource and datasource field from the form that holds data used to find the right contact with.
The last thing, is to control how the contact person is found and set up a PresenceInfo object. 

There are different approaches for different kinds of key data. Here AX looks at the extended data source of the PresenceDataField that you specified on the form field. 

On the extended data type there are two properties pointing to the class method doing the job of finding the contact person. The properties are PresenceClass and PresenceMethod. I think all standard implementations of these point to the DirPresenceInfo class as the PresenceClass. If you examine this class you can see how it based on different kinds of keys finds the right contact person and creates a PresenceInfo object for the contact.

That's all.