Create Outlook event using two different Time/Date fields - InfoPath Dev
in

InfoPath Dev

Create Outlook event using two different Time/Date fields

Last post 01-20-2010 01:50 PM by Nate@GLRM. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-15-2010 12:15 PM

    Create Outlook event using two different Time/Date fields

    I have an Infopath form that I am using to create an Outlook calendar event amoung a couple other things.  I hard coded the dates for test purposes and it worked like a charm!  Now I have two fields (one for date and one for time) that I need to use to schedule an Outlook appointment.  I am not familiar with pulling fields from Infopath into a variable, so I may need some help with this.

    I'm using VBScript with the following code:

    Set objOutlook = CreateObject("Outlook.Application")
    Set itmAppt = objOutlook.CreateItem(1)

    itmAppt.Start = "1/15/10 3:30PM" 'This needs to be assigned to the data the Time and Date fields in the form
    itmAppt.Duration = 60
    itmAppt.Subject = "Test Appointment"
    itmAppt.AllDayEvent = False
    itmAppt.ReminderSet = True
    itmAppt.ReminderMinutesBeforeStart = 60
    itmAppt.Body = "Test Body"
    itmAppt.Save

    Any help will be much appreciated!

  • 01-17-2010 03:46 PM In reply to

    Re: Create Outlook event using two different Time/Date fields

    You'll need to figure out the XPath to the date field in your form and replace the XPath in the below sample with that:

    Dim dateNode
    Set dateNode = XDocument.DOM.selectSingleNode("/my:myFields/my:dateField")

    Will get you the xml node. Then, to get the text:

    dateNode.text

    So, you could modify what you have to look like: 

    Dim dateNode
    Set dateNode = XDocument.DOM.selectSingleNode("/my:myFields/my:dateField")

    Set objOutlook = CreateObject("Outlook.Application")
    Set itmAppt = objOutlook.CreateItem(1)

    itmAppt.Start = dateNode.text

    ......

    You may want to add some error handling, make sure that there is a value in dateNode.text.If you are using separate fields for the time and date, you'll need to get both values, make sure they aren't blank, and concatenate them. Good luck, and holler if you get stuck.

    Hilary Stoupa

  • 01-19-2010 10:42 AM In reply to

    Re: Create Outlook event using two different Time/Date fields

    I am using Infopath 2003, how do I figure out the XPath of a field?

  • 01-19-2010 02:38 PM In reply to

    Re: Create Outlook event using two different Time/Date fields

    If you save your form as source files, you can open template.xml in a text editor -- that gives you a pretty good idea of the XPath. Another way is to add an expression box to your template, just on the surface itself, not inside of any groups or sections, and select the field you need the XPath for as the XPath for the expression box. If you look in the expression box's properties, you can see the XPath (or select Edit XPath in the fx formula editor).

    If you get stuck, post your template here, under the Options tab there is a spot to attach a file, so that someone can help you with your XPath.

    Hilary Stoupa

  • 01-20-2010 01:18 PM In reply to

    Re: Create Outlook event using two different Time/Date fields

    I attached the template, with the code that I have it looks like dateNode.text is not being recognised.  Thank you for your help!

  • 01-20-2010 01:26 PM In reply to

    Re: Create Outlook event using two different Time/Date fields

    The XPath to your date field is /my:myFields/my:field29

    I would highly recommend you take a little time and clean up your main data source before you put this into production. Remove all unused fields, and give the fields you are using meaningful names. It will make things easier for you when the form needs revisions....

    Hilary Stoupa

  • 01-20-2010 01:50 PM In reply to

    Re: Create Outlook event using two different Time/Date fields

    Thank you very much, it works!  For the purposes of confidentiality some form fields were excluded from my template and not named but I do need to do a better job of naming fields, thank you for your guidance. 

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.