Wednesday, August 22, 2012

Query a User's Schedule for Open Time Slots Using VB.NET in Microsoft Dynamics CRM 2011

This illustration shows how to query a user's schedule for open time blocks using VB.NET  in Microsoft Dynamics CRM 2011 with QueryScheduleRequest.
    Ok, here is what the code looks like!
    In VB.NET

    Dim reqWAI As New WhoAmIRequest()
    Dim respWAI As WhoAmIResponse = DirectCast(_serviceProxy.Execute(reqWAI), WhoAmIResponse)
    Dim reqSchedule As New QueryScheduleRequest()
    reqSchedule.ResourceId = respWAI.UserId
    reqSchedule.Start = DateTime.Now
    reqSchedule.End = DateTime.Today.AddDays(3)
    Dim tmc As New TimeCode()
    tmc = TimeCode.Available
    reqSchedule.TimeCodes = New TimeCode() {TimeCode.Available}
    Dim respSchedule As QueryScheduleResponse = DirectCast(slos.Execute(reqSchedule), QueryScheduleResponse)
    If respSchedule.TimeInfos.Length > 0 Then
        'act on timeslots
        'user has no free time that meets these parameters
    End If

    If you need help instantiating a service object in .NET within a plugin check out this post:

    I hope this helps!

    No comments:

    Post a Comment