Getting context contacts for Lync 2013 custom command (Lync SDK)

706 views Asked by At

I'm developing a small solution for Lync 2013, based on custom commands.
In short: I added a button to Lync. The button is visible upon right-clicking on contacts and from a conversation window.

I'd like to be able to get the relevant contact\conversation when the button is clicked.
%contact-id% works well with right-clicking on contacts. my EXE is launched, and all is well.
However, using it on an open conversation prevents the EXE from being launched at all.
If I remove the %contact-id%, my EXE is launched, but then I don't have the relevant contacts.

Am I doing something wrong? How do I get this information?


(I did see an approach that suggests to have a windows service that tracks Lync open windows and knows later to map hWnd to conversation. I really don't want to go there. It's way to complex and too big for my needs. Also, I'm not sure it'll work in Lync 2013, as all Conversation are in the same tab)


I also tried to use Conversation Window Extension, but it seems to have the same problem.
I thought I'll be able to send contextual data to the other contacts of the current conversation, but I didn't find a way to get the current conversation and therefore I wasn't able to use the beginSendContextData.


Update:
I managed to get the context conversation, using LyncClient.GetHostingConversation()

But using CWE leads to a very bad user experience. Is there a way to get the Hosting conversation without CWE..?

1

There are 1 answers

0
user1909402 On

We can confirm that the parameter %contact-id% is not transmitted if the custom command is triggered from within the conversation window. In this case, the custom command just does not get executed, it's .exe file doesn't get launched.

This leaves you with the option to detect the current conversation programmatically. Unfortunately there seems no obvious way to detect the currently displayed conversation reliably. You can try to check all conversations in the ConversationManager and use some hints:

  • ConversationManager.Conversations.Last() The last created conversation, not necessary the one where the user used to click the custom action.

  • Conversation.State == ConversationState.Active Sending a message switches the state to Active, but more than one conversation can be active.

  • Conversation.Properties[ConversationProperty.Inviter] The inviter is the user logged in to the local lync client, the one with %user-id%.

  • Conversation.Properties[ConversationProperty.LastActivityTimeStamp] A timestamp when the conversation received the last message.

http://msdn.microsoft.com/en-us/library/microsoft.lync.model.conversation.conversationproperty_di_3_uc_ocs14mreflyncclnt.aspx

But still these bits of information are only hints and are not sufficient to reliably detect the current conversation that is displayed to the user. We are still looking for a reliable way to detect it.