Determine 'Week Of' or 'Week Ending' based on DatePicker control - InfoPath Dev
in

InfoPath Dev

Determine 'Week Of' or 'Week Ending' based on DatePicker control

Last post 10-16-2012 11:42 AM by Gennady Vanin (Геннадий Ванин, Новосибирск). 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-16-2012 05:15 AM

    • APMOB
    • Not Ranked
    • Joined on 09-06-2012
    • Posts 6

    Determine 'Week Of' or 'Week Ending' based on DatePicker control

    Hi all,

    Have been browsing for this already and suspect it is either a) impossible or b) quite complicated to achieve, but figured it's no harm to ask anyway...

    I'm designing a form template which will have multiple sections based on daily, weekly or monthly data.

    Above each section I have a date picker to allow the user to specify exactly what period they are reporting on (so three independent date pickers)

    I want to format the displayed date based on the period - for Daily and Monthly, this isn't a problem, as I can just set the format of the control to be either dd-mmm-yyyy (Daily) or mmm-yyyy (Monthly) and it will show perfectly. The problem arises for Weekly, as there is no pre-defined format for 'Week Ending' (which could then show the date of, say, the preceding Friday?) or 'Week Of' (which could show a date range from Monday to Friday, á la "15-19 October 2012")

    My intention was to add a text-box next to the date-picker and add a rule / formula to populate the text box based on the date-picker value. So the user could pick a random date in the date-picker and the text-box would populate one of the two formats described above (i.e. the date of the preceding Friday, or the dates of both the preceding Monday and Friday - whichever I can achieve!)

    The problem is obvious; I don't know how to put such a formula together based on the pre-defined formulas that are available in the GUI (absence of 'IF' or 'WEEKDAY' functions, to use Excel/VBA as an equivalent) and suspect such a formula may not even be possible.

    So I'm guessing this can only be done through code, but while I could knock this up in VBA in 2 minutes, I'm new to coding in InfoPath (does it use C / C++?...) And also concerned about adding code-based functionality as the end-users may not have InfoPath installed and not sure if that would be a requirement in order to have this kind of code running in the background?...

    Thanks in advance for any pointers you can give?

    APMOB

  • 10-16-2012 09:06 AM In reply to

    Re: Determine 'Week Of' or 'Week Ending' based on DatePicker control

    APMOB:
    I'm new to coding in InfoPath (does it use C / C++?...)
     

    It can use C# 2.0 (aka 2005) or VB.NEt (Visual Basic.NET) 2.0 (aka 2005).

    You will find how to enter into coding under Developer tab on ribbon in Infopath Designer 2010

    Somewhen before 2010 it was using JScript , in 2003, not sure abt 2007.

    APMOB:
    may not have InfoPath installed and not sure if that would be a requirement in order to have this kind of code running in the background?
     

    If you intend to use Infopath Filler/client   form then clients should have Infopath installed even if you use codeless forms. 

    If you are going to run then through browsers then it is available only through enterprise Sharepoint Server Infopath Form Service and you should not worry about clients.  

    You should avoid coding due to maintenance hassles and I people manage to create very complicated algorithms with dates codelessly

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 10-16-2012 09:30 AM In reply to

    • APMOB
    • Not Ranked
    • Joined on 09-06-2012
    • Posts 6

    Re: Determine 'Week Of' or 'Week Ending' based on DatePicker control

    Many thanks Gennady!

    Agree on the advice to avoid coding where possible; I've managed to utilise an elaborate formula to apply a rule / data validation combo to force users to only select a Friday on a date-picker. Link below for anyone else with the same requirement :

    http://www.bizsupportonline.net/infopath2007/force-select-day-of-week-date-picker-infopath-using-rules-formulas.htm

    Which allows me to use the date picker as a 'Week Ending' value and thus solves my problem!

    To your point on availability of InfoPath to end-clients, the forms are to be published on a SharePoint site which I'm hoping gets around any issue of whether they have it installed or not (I take from your answer that it should?)

     Thanks again for the info, much appreciated!

    APMOB

  • 10-16-2012 11:42 AM In reply to

    Re: Determine 'Week Of' or 'Week Ending' based on DatePicker control

    APMOB:
    the forms are to be published on a SharePoint site which I'm hoping gets around any issue of whether they have it installed or not (I take from your answer that it should?)
     

    Publishing to a Sharepoint is somewhat unrelated to where the form will be opened. 

    If you publish a filler XSN form template then the users will be able open created on its basis XML data forms from sharepoint only in Filler (on client machines) and attempt to open in browser will produce an error..
    While browser -enabled forms can be opened both in Filler (on client machines, which requires Infopath installed on client machines) and in browser (on Sharepoint Server).

    The Web Browser form will have both choices and I do not know how OOTB to restrict the context options to opening only in Filler or to only in browser.


    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.