date stamp when view 2 opens

K

Karyl

This seems so simple but I have not been able to get it to work successfully.
I have a routing form with several views. I need to know when view 2 is
opened by the email recipient. I have installed a text box with a value =
today() and have unsuccessfully tried rules and conditional formatting with
replydate = today() and read only. So far my results provided the date view 1
is opened instead of when view 2 was opened. Hoping some of you genius
InfoPathers can help.
 
F

Franck Dauché

Hi Karyl,

You could do this by code with the OnSwitchView event. In there, you want
to compare the thisXDocument.View.Name with your view2 name, and set your
"today()" value by code only when they are equal.

Hope that it helps.

Regards,

Franck Dauché
 
K

Karyl

I am not a programmer and relatively new to InfoPath - could you be more
specific?
 
F

Franck Dauché

Hi Karyl,

I am assuming that you are using scripting behind your form.

Part 1:

Create a new form in InfoPath and add a second View: View 2.
Write View 1 on top of the View
Drop 2 buttons on View1 (with captions "go to view 1" and "go to view 2",
respectively.
Righ-click on the 1st button go to Properties and click "Edit Form Code..."
in the function write: XDocument.View.SwitchView("View 1");
go back to your form, do the same thing for the other button, but this time
write: XDocument.View.SwitchView("View 2");
In IP, Copy these 2 buttons on view2 (put a title also)
In the InfoPath menu, go to Tools / Programming / and picked the "On Switch
View Event" choice
You are now in the scripting window, and you are looking at: function
XDocument::OnSwitchView(eventObj)
try to put: XDocument.UI.Alert(XDocument.View.Name);

run your form and click on the buttons....voila.

Part2:
You need to replace the nice alert above by code:
var node = XDocument.DOM.selectSingleNode("/my:myFields/my:field1") Need to
put your XPath there
node.text = getToday();

under that function, you put:

function getToday()
{
var oDate = new Date();
var m = oDate.getMonth() + 1;
var d = oDate.getDate();
if (m < 10)
m = "0" + m;
if (d < 10)
d = "0" + d;
return oDate.getFullYear() + "-" + m + "-" + d;
}

Should help you getting started.

Regards,

Franck Dauché
 
K

Karyl

I am not using scripting - Have never learned scripting...do I need to? Or
can I just use InfoPath rules or conditions?
 
K

Karyl

In re-reading your response I think you may have misunderstood my original
question...Let me try to reword and be more specific.

I have an existing form with 5 views which switch depending on the rules
I've installed. Now the requester (View 1) wants to know when the recipient
of View 2 actually opened up the form in their mailbox - Like a read receipt
- so when it is routed to View 3 - they will know the date the form was
opened. I need to put the date the View 2 form was opened in a text box on
the form. Can I do this just using rules and conditions or do I have to
write script? Sorry for my error in explaining this more clearly...I
sincerely appreciate your help.
 
F

Franck Dauché

No, you don't have to. But I have a feeling that your business rules are
more complex than what Rules offer...maybe not!
OK. You need to add 5 text fields (one per View: fld1, through fld5).
At the form level, you need rules:
If fld1 is blank, switch to View1 (form was untouched).
When the 1 person saves the form, you need to set fld1 to "today()" by rule.
Next the form is sent to the second person:
Another rule at the form level needs to be Conditions: If fld1 is not blank
AND fld2 is blank, Actions: switch to View2 AND set field's value (fld2 =
today()) AND send email (Submit using data connection..)
and so on.
You need to build a complex set a rules at the form level, but I am afraid
that you may reached a Rule limitation at some point.

Does it make sense?

Franck Dauché
 
F

Franck Dauché

You too, and good luck with your infoPath developments.
If you have questions, don't hesitate to come back and open a new thread.

Regards,

Franck Dauché
 
K

Karyl

To all my fellow InfoPath friends - This worked -

I opened my "View2" in design mode - Went to Tools/Form Options/Open &
Save/Rules

Chose the rule that did the switch and added "Set Field Value: replyDate =
Today()

My users are happy and so am I!! Thanks Frank
 
F

Franck Dauché

Hi Karyl,

You are welcome. I am glad I could help.
If any of my posts was useful, don't hesitate to rate it as it will be
easier to spot for others that are experiencing identical issues.

Thanks.

Regards,

Franck Dauché
 

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