Agenda that determines the content of a form

K

Koen Alleman

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

S.Y.M. Wong-A-Ton

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-xdextensions.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.
 
K

Koen Alleman

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?
 
K

Koen Alleman

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.
 
S

S.Y.M. Wong-A-Ton

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?frame=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/e...aveAsDialogLocation_HV01103988.asp?frame=true)
and the SetSaveAsDialogFileName
(http://msdn.microsoft.com/library/e...aveAsDialogFileName_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/e...ml/odc_InfoPath_extending_save.asp?frame=true
 
K

Koen Alleman

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?
 
S

S.Y.M. Wong-A-Ton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top