JavaScript Date formatting

JavaScript has some powerful built in features, however one let down (for me) is it’s ability to format date strings off the bat. In a recent project I needed to achieve just that.. Going from a string 1/11/2013 to 01 November 2013. Something which seemed so simple turned out to require a function all of it’s own.

So here’s how I did it:

Read More

Get current Sharepoint user manager details using JavaScript

We have recently started to deploy Sharepoint solutions around the business, and I was asked to customise one of them to include personalisation’s around the current user. One of those personalisation was to retrieve the current users ‘line manager’ details.

The following code is what I have come up with, this is work in progress, and not yet quite finished. I am sure there is an easier way to do this.. However a tight deadline meant I had to make it work, then work on perfecting it. If anyone has a better way of doing this I would appreciate a comment below.

Read More

Automated Lync Dial testing using VB.net

Today I was asked if it would be possible to ‘Automate’ the repeated dialling of a SIP contact, this was in order to try and replicate and resolve an issue with a headset and lync.

So I cam up with this, and thought I should share it in case others find it useful.

The code below commences dialling after the command button is pushed, and each time the other party hangs up the App starts dialling again. Simple but effective.

If you use the code, or figure out a better way of doing it drop me a message using the comments section below.

Read More

Handle Lync Audio/Video ModalityStateChanged with VB.net

da57591e-7377-46d3-959c-005816e755c4So todays challenge was around handling the ModalityState change on the Lync 2013 client. The ModalityState change event happens during certain stages of Lync calls, and client actions. The ModalityState is part of the Microsoft.Lync.Model.Conversation namespace. We are using it to configure certain custom Lync Status’ dependant of the current state of the client.

To capture and handle these events, you need to create and event handler for the conversation manager namespace and for ModalityStateChangedEventArgs. The code below is written in VB.Net but could easily be transferred to C# etc.

In my example, I am only interested in the AudioVideo modality state changes.

Imports Microsoft.Lync.Model
Imports Microsoft.Lync.Model.Conversation
Imports Lync = Microsoft.Lync.Model.Conversation

Public Class frmMain
    Private _LyncClient As LyncClient
    Public WithEvents _ConversationMgr As Microsoft.Lync.Model.Conversation.ConversationManager
    Public WithEvents _conv As Conversation

    Private Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            _LyncClient = LyncClient.GetClient()
            _ConversationMgr = _LyncClient.ConversationManager
            DisplayCurrentState()
        Catch generatedExceptionName As ClientNotFoundException
            MessageBox.Show("client is not running")
        End Try
    End Sub

    Private Sub _ConversationMgr_ConversationAdded(ByVal sender As Object, ByVal e As Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs) Handles _ConversationMgr.ConversationAdded
        AddHandler e.Conversation.Modalities(ModalityTypes.AudioVideo).ModalityStateChanged, AddressOf AVModalityStateChanged
    End Sub

    Private Sub AVModalityStateChanged(ByVal sender As Object, ByVal e As ModalityStateChangedEventArgs)
        Select Case e.NewState
            Case ModalityState.ConnectingToCaller
                'Insert your code here
            Case ModalityState.Connecting
                'Insert your code here
            Case ModalityState.Joining
                'Insert your code here
            Case ModalityState.Transferring
                'Insert your code here
            Case ModalityState.Disconnected
                'Insert your code here
            Case ModalityState.Disconnecting
                'Insert your code here
            Case ModalityState.Forwarding
                'Insert your code here
            Case ModalityState.OnHold
                'Insert your code here
            Case ModalityState.Suspended
                'Insert your code here
        End Select
    End Sub

So as you can see, it’s quite a simple concept – which holds lots of potential!

Read More

Mass Outlook Calendar Cleanup

Over the last few weeks the company that I work for have been migrating from Google Apps over to Microsoft 365 for mail/calendar/contacts and unified messaging etc. This has not been without it’s challenges. Some have which have been fairly bizarre. This week I was approached by a member of our department who had somehow managed to end up with 10,000+ appointments of the same title in his calendar. We set about trying to remove them on mass using the Outlook GUI, but soon realised this would take a very long time. Which is when I put together the following snippet of VBA:

NB: This code ‘takes no prisoners, and straight deletes the appointments matching the criteria you pass it. This wouldn’t be easy to undue if you ran with incorrect parameters. I’d advise adding a break point and testing a few before letting it hit your entire calendar folder.

Dim myNameSpace As NameSpace
Dim myCalendar As Folder
Dim myAppts As Items
Dim myAppt As AppointmentItem
Dim i As Integer

Sub purge_cal()
    Set myNameSpace = Outlook.Application.GetNamespace("MAPI")
    Set myCalendar = myNameSpace.GetDefaultFolder(olFolderCalendar)

    Set myAppts = myCalendar.Items
    i = 0
    For Each myAppt In myAppts
        If myAppt.Subject = "" Then
            i = i + 1
            Debug.Print "Deleting " & myAppt.Subject
            myAppt.Delete

        End If
    Next
        Debug.Print i & " calendar items deleted"
End Sub

Read More