/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to open calendar on a specific date

  • Creator
  • #4050

    I wanted to write an applet to show a user an appointment in their calendar:
    eg, when they recieve an appointment, they click a button, and it automatically opens their calendar on that date, so they can see how it fits in with their other appointments.

    I have currently got
    GroupWise.DateAbsoluteGoTo GroupWise.ParseDay …. etc.

    The problem is that DateAbsoluteGoTo sets the date for the calendar folder (as shown in the folders list), and OpenCalendar opens a new calendar window on today’s date. What I wanted was to open either view, with the date set to the date of the appointment. I feel like I have missed something fundamentally obvious here … can someone please enlighten me?


  • Author
  • #6961
    Support 1

    Thank you for your enquiry.

    In the following, I make the following assumptions; that you require:

    • a new button on the GroupWise client main toolbar;
    • the appointment to be selected in the message list;
    • clicking the new button opens a calendar view matching the appointment start date.
    Sub Main(Client, GWEvent)
      dim iStartDate
      dim oMessage
      ' Suppress error handling on .CommandMessage if no message is selected.
      on error resume next
      set oMessage = nothing ' initialize to something we can compare
      set oMessage = Client.ClientState.CommandMessage
      ' Turn on error handling.
      on error goto 0
      if oMessage is nothing then
        MsgBox("There is no message selected.")
        ' Ensure it's an appointment.
        if InStr(1, oMessage.ClassName, "GW.MESSAGE.APPOINTMENT", vbTextCompare) = 1 then
          iStartDate = oMessage.StartDate
          call GroupWise.ViewOpenNamed("Appt (sm)", VIEWTYPE_CALENDAR, "")
          call GroupWise.DateAbsoluteGoTo(Day(iStartDate), Month(iStartDate), _
          MsgBox("Your selected message is not an appointment.")
        end if
      end if
      set oMessage = nothing
    End Sub

    You can see the available view names, like ‘Appt (sm)’, listed in the drop-down menu of the Open Calendar button on the GroupWise toolbar.

    I hope this helps.

    Advansys Support


    It was the following line I failed on:
    GroupWise.ViewOpenNamed “Week”, 1, “”)

    I see now that it is important to have the lines in the correct order.


    and not the other way around (apparently, DateAbsoluteGoTo applies to the ‘current calendar view’, which by default is the main calendar view – OpenCalendar apparently does not create a real ‘view’, whatever that is …).

    Hope this helps other people avoid the same problem later.


    Oh, and thanks, before I forget Big Grin


    Ok, I don’t know if this is your problem or GroupWise’s problem, but it gets the date format wrong under certain circumstances.

    As we are in UK, we use the British date format on our computers. However, because I had not configured it to do so, GroupWise was still using US date format (the default). When it opens the calendar window, and sets the date, it sets the date assuming the date is written in the format of the system, not the date format of GroupWise.

    Support 1

    I am glad to have been able to help.

    Another option, that avoids potential internationalization problems, is:

      call GroupWise.ViewOpen(vwtCalendar, TRUE, "")

    Regarding the date format issue, I am not sure what you mean by ‘wrong under certain circumstances.’ As I understand it, GroupWise always uses the formats specified on the Format tab of the Date Time Options dialog. If the default is the US date format, this is a flaw; I would expect the default format to follow the System format.

    Please see your Forum thread GroupWise vs system date format for further comments on the date format.

    Advansys Support


    The potential problem is that, as you have stated, GroupWise always uses the formats specified on the Format tab of the Date Time Options dialog. However, Formativ uses the date format specified by the operating system. As these may be different (which is why GroupWise has the ‘set GroupWise to system’ button), it is possible for Formativ to misinterpret dates on GroupWise items.

    This means that my applet opens the calendar on the wrong date if GW and the OS are set up to use different date formats. It’s not a major issue, just a warning.

    Support 1

    I think you are referring to a GroupWise Token API method for obtaining a message date, like:

      dim iDateStr
      iDateStr = GroupWise.ItemGetDate(...)

    This method returns a string representation of the date. The Token API also has methods for parsing a date string eg. GroupWise.DateParseDay(), but I notice the online documentation is vague on how to get ItemGetDate() and DateParseDay() to agree on a date format.

    We have only a little experience with handling these string-typed GroupWise dates. In fact, we strongly recommend that applet writers avoid processing string dates, due to the date format problem you have discovered.

    It is simpler by far to work with a Date variable in your Formativ scripting, and to extract date components as necessary using VBScript functions like Day(), Month(), Year(). This is why the example applet in my earlier post uses the Formativ object model (Client.ClientState) to obtain a reference to the relevant message.

    Note: if you have already obtained a message ID string using the Token API, you can obtain an object reference to the message as follows:

      dim iMessageID
      dim oMessage
      ' Initialize iMessageID
      ' ...
      set oMessage = GroupWise.Account.GetMessage(MessageID)

    Note: you can find more information about the ClientState object in the Applet Structure section of the Formativ Programmers Guide.

    Once again, thank you for drawing attention to this gotcha.

    Advansys Support

    [This message was edited by Support 3 on April 21, 2004 at 09:00 PM.]

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.