Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

Agenda that determines the content of a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Koen Alleman - 24 Mar 2006 10:04 GMT
Hey

I am trying to design a sort of agenda-system where employees can input data
on a daily basis. Appointments, reservations, internal affairs, etc...

So I want to make one form with Infopath in which it is possible to do this.
Here is the description of the desired form:

A user opens the form and selects a date (on top of the form). Depending on
what day it is, the input-areas in the form change (Note: the agenda is
different each day (Monday, Tuesday, ..., Sunday) for example: on Monday
points A, B, C and D are mentioned on the agenda; but on Tuesday points B, D,
E and F are listed). So if the users selects a day (for example
22-03-2006)(with the standard date element in Infopath) there must be a
script that says "Hey, the 21nd of March is a Tuesday, so now I must show
points B, D, E and F so the user can fill them in".

Questions is: how do I do this?

Working with 7 different views (one for each day of the week) and then
what...?
With a script? And does anyone have the time to make that (if it doesn't
allready exist)? As I know nothing about scripting.

Or something totally different?
I'm open for suggestions.

I hope to get a swift answer
Koen
S.Y.M. Wong-A-Ton - 24 Mar 2006 15:13 GMT
This cannot be done without programming of some sort, since you want to
retrieve the day of the week from a given date - functionality that is not
available in InfoPath without coding. Look into the Help file of the
Microsoft Scripting Editor or on http://www.microsoft.com/scripting for more
information on programming in JScript or VBScript.

As for your scenario, I would suggest using a section for each day of the
week along with conditional formatting that makes use of an xdExtension that
calls into a JScript function to retrieve the day of the week and show/hide
each section. For more information on xdExtensions see
http://blogs.msdn.com/infopath/archive/2005/06/17/430347.aspx

I liked your scenario so much that I put together a "recipe" (=solution) and
posted it on my website (see
http://enterprise-solutions.swits.net/infopath/switch-day-sections-jscript-xdext
ensions.htm
).
Note: I don't do this often. :)  But  I think it will show the power of using
xdExtensions in InfoPath well; a much underused but useful feature.
---
S.Y.M. Wong-A-Ton

> Hey
>
[quoted text clipped - 25 lines]
> I hope to get a swift answer
> Koen
Koen Alleman - 27 Mar 2006 09:46 GMT
Thanks mate

There is yet one small issue to deal with.

We also work in weekends (Saturday and Sunday).

So I made 7 sections in stead off 5 (in step 4).
I also adjusted step 14 with saturday being <<xdExtension:isDay(6) =
false()>> and sunday being <<xdExtension:isDay(7) = false()>>.

It works great, exept for Sundays.
If I choose a Sunday, nothing happens. I don't see the "Sunday" I've typed
in the 7th section.

How can I solve this? Has it something to do with the JScript code?

> This cannot be done without programming of some sort, since you want to
> retrieve the day of the week from a given date - functionality that is not
[quoted text clipped - 15 lines]
> ---
> S.Y.M. Wong-A-Ton
S.Y.M. Wong-A-Ton - 27 Mar 2006 12:01 GMT
For Sunday use xdExtension:isDay(0) = false()
---
S.Y.M. Wong-A-Ton

> Thanks mate
>
[quoted text clipped - 31 lines]
> > ---
> > S.Y.M. Wong-A-Ton
Koen Alleman - 27 Mar 2006 14:41 GMT
Works great, thanks.

I got another question. Knowing that I followed S.Y.M. Wong-A-Ton's advise,
I now got a form with a date on top.

If I fill in the form, and click "save".
Infopath asks me in what folder it has to save and what the name of the form
is.
That name is "Form1"

Can I change this, so that when I click "save", it automatically shows me
the date I've just set in my form?

This form must be used in network by most of my employees. If I don't use a
uniform name for all my files, every employee will give a different name to
his/her filled-in form.

> For Sunday use xdExtension:isDay(0) = false()
> ---
> S.Y.M. Wong-A-Ton
S.Y.M. Wong-A-Ton - 27 Mar 2006 18:41 GMT
You would have to retrieve the date (just as the JScript function does) and
then compose a unique name for the form. You can then override the save
behaviour through Tools > Form Options > Open and Save tab > Save using
custom code. Look into using XDocument.SaveAs (see
http://msdn.microsoft.com/library/en-us/ipsdk/html/xdmthSaveAs_HV01021407.asp?fr
ame=true
)
to be able to specify the form's name. There have been many posts discussing
this issue, so you could do a Google search in this newsgroup to find sample
code.

You can also look into SetSaveAsDialogLocation
(http://msdn.microsoft.com/library/en-us/ipsdk/html/xdmthSetSaveAsDialogLocation_
HV01103988.asp?frame=true
)
and the SetSaveAsDialogFileName
(http://msdn.microsoft.com/library/en-us/ipsdk/html/xdmthSetSaveAsDialogFileName_
HV01103987.asp?frame=true
).
I haven't tried these myself, but they look promising for your scenario.

This article also contains many helpful hints and suggestions:
http://msdn.microsoft.com/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extendin
g_save.asp?frame=true

---
S.Y.M. Wong-A-Ton

> Works great, thanks.
>
[quoted text clipped - 16 lines]
> > ---
> > S.Y.M. Wong-A-Ton
Koen Alleman - 29 Mar 2006 09:21 GMT
Ok, so this is what I got untill now:

public void OnSaveRequest(SaveEvent e)
{
   
   string datum = thisXDocument.DOM.selectSingleNode
       ("//my:mijnVelden/my:datum").text;
   if (thisXDocument.IsNew == true || e.IsSaveAs == false)
   {
       if (e.IsSaveAs == true)
       {
           thisXDocument.UI.SetSaveAsDialogLocation("c:\\temp");
           thisXDocument.UI.SetSaveAsDialogFileName(datum);
       }
       e.IsCancelled = e.PerformSaveOperation();
       e.ReturnStatus = true;
   }
   else
   {
       thisXDocument.UI.Alert("The 'Save As' functionality
           is disabled for forms that are not new.");
   }
}

Yet it doesn't work.
Error message when I open the form:
';' is expected
File:script.js
Line:35
public void OnSaveRequest (SaveEvent)

Can anyone help?

> You would have to retrieve the date (just as the JScript function does) and
> then compose a unique name for the form. You can then override the save
[quoted text clipped - 15 lines]
> ---
> S.Y.M. Wong-A-Ton
S.Y.M. Wong-A-Ton - 29 Mar 2006 11:24 GMT
You cannot just copy and paste the code from the article into your InfoPath
form, since it is using C# .NET code and not JScript. So you either have to
have Visual Studio .NET installed to be able to use managed code with your
InfoPath forms or convert the code in the article to a JScript version.
---
S.Y.M. Wong-A-Ton

> Ok, so this is what I got untill now:
>
[quoted text clipped - 48 lines]
> > ---
> > S.Y.M. Wong-A-Ton
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.