BLOCKED SCRIPT Working out which business year the current date is within - InfoPath Dev
in

InfoPath Dev

BLOCKED SCRIPT Working out which business year the current date is within

Last post 09-22-2009 05:32 PM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-22-2009 06:18 AM

    BLOCKED SCRIPT Working out which business year the current date is within

    Hi i'm new to VBScript in Infopath 03, so sorry if this I sound like an idiot.

    I'm trying to set a Start Date and an End Date based on Todays Date, its worth mentioning now i'm from the UK, so the day and month are the other way round. I want the start and end date to be between 01.04.*year* and 31.03.*year +1*

    So for example if todays date was 12.12.09, the start and dates would be worked out as  01.04.2009 and 31.03.2010.
    Also if todays date is 24.02.2010, the start and dates would still be 01.04.2009 and 31.03.2010. Hopefully thats easy enough to understand.

    todays date is worked using the date() function by the Open Behaviour rules in Form Options, so it will always have the current date when the form is opened - "DD/MM/YYYY". No date picker is used. 

    Heres, the code i've managed so far, any help on this would be very much appreciated smile.gif  

     

     

    XDocument.DOM.setProperty "SelectionNamespaces", "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"" xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:xdEnvironment=""http://schemas.microsoft.com/office/infopath/2006/xslt/environment"" xmlns:xdUser=""http://schemas.microsoft.com/office/infopath/2006/xslt/User"" xmlns:xsf2=""http://schemas.microsoft.com/office/infopath/2006/solutionDefinition/extensions"" xmlns:xhtml=""http://www.w3.org/1999/xhtml"" xmlns:tns=""http://tempuri.org/"" xmlns:mime=""http://schemas.xmlsoap.org/wsdl/mime/"" xmlns:tm=""http://microsoft.com/wsdl/mime/textMatching/"" xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:soap=""http://schemas.xmlsoap.org/wsdl/soap/"" xmlns:http=""http://schemas.xmlsoap.org/wsdl/http/"" xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"" xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-02-16T14:02:17"" xmlns:xd=""http://schemas.microsoft.com/office/infopath/2003""" ' '======= ' The following function handler is created by Microsoft Office InfoPath. ' Do not modify the name of the function, or the name and number of arguments. '=======

    Dim dtToday, dtStart, dtEnd

    Dim dtYear, dtMonth, dtDay

    Sub XDocument_OnLoad(eventObj)

     dtToday = XDocument.DOM.selectSingleNode("my:myFields/my:dtToday").Text

    'Code Here

    'XDocument.DOM.selectSingleNode("my:myFields/my:dtStart").Text = dtStart

     'XDocument.DOM.selectSingleNode("my:myFields/my:dtEnd").Text = dtEnd

     End Sub

    Filed under: ,
  • 09-22-2009 05:32 PM In reply to

    Re: BLOCKED SCRIPT Working out which business year the current date is within

     You don't need script for this.  You can just set the fields' default values to these formulas:

    StartDate:

    concat(substring(today(), 1, 4), '-04-01')

    EndDate:

     concat(substring(today(), 1, 4)+1, '-03-31')

     

    And remember to uncheck "Update this value when the result of the formula is recalculated."

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.