Hi! Thanks in advance for any help!
What I want is a "need by" date ("DateNeededBy") that the user chooses, but that date can not be a weekend nor can it be in the past, today, or tomorrow.
I've solved the weekend issue creating a "DayOfWeekNumber" variable and setting up a rule in "DateNeededBy" to assign an integer value to the day of the week it happens to be. I then used a validation condition to restrict Saturdays and Sundays. Here's the code if anyone is interested:
(number(substring(., 9, 2)) + floor(((153 * (number(substring(., 6, 2)) + (12 * floor((14 - number(substring(., 6, 2))) / 12)) - 3)) + 2) / 5) + (365 * (number(substring(., 1, 4)) + 4800 - floor((14 - number(substring(., 6, 2))) / 12))) + floor((number(substring(., 1, 4)) + 4800 - floor((14 - number(substring(., 6, 2))) / 12)) / 4) - 32083) mod 7
That's working fine. My issue is preventing dates from the past, today, and tomorrow from being entered. Obviously the following validation does not work...
DateNeededBy | is less than or equal to | today()
... because that only does the past and today. And I know that I can not use a simple calculation to add a day. I also know that this would be much easier in IP2007 but upgrading is not an option (we're talking about thousands of users in a corporate environment).
So I'm down to VB code, which I'm not very familiar with.
Thanks to Clay Fox's information in this post - http://www.infopathdev.com/forums/p/1192/4234.aspx#4234 - I've been able to calculate tomorrow's date and return it to a variable in the form:
Sub XDocument_OnLoad(eventObj)
XDocument.DOM.selectSingleNode("/my:myFields/my:HiddenVariables/my:Tomorrow").text = DateAdd("d",1,date)
End Sub
"Tomorrow" is a Text(string) data type.
My problem now is that InfoPath doesn't see this returned information as a real date. When I set the "Tomorrow" variable as a Date(date) data type, I get nothing in my form.
It looks to me like the information that the VB code is outputting is not in the format that InfoPath likes to see as a date. I know that there are differences in formats, so my assumption now is that I need some additional code in VB to convert that VBScript date that's being generated in the above code to ISO format that InfoPath needs. Is that correct?
Now, here's where the help comes in :) ! I have NO idea how I would do that. Can anyone help out?
Thank you!