Time clock/counter

D

danib37

I am creating a time tracker form for team members to log an activity, and
the time spent on the activity. The team member would enter the activity,
click a button to record the start time, and when finished with the activity,
click another button to record the end time. It then needs to calculate the
difference between the two times.
Thanks for any suggestions!
 
A

Anuma(GGK Tech)

Hi,

Using following steps Set the time when we click on the Button:
1. Add “StartTime†and “EndTime†fields to the scheme.
2. Double click on the button and click on edit form code. And use following
code.
Time = DateTime.Now.ToString("HH:mm:ss");
thisxdocument.SelectSingleNode("StartTime", Time).text;
StartTime --> Enter your start Time field xpath
Use same above steps to set end time value.

Verify the below links to calculate the time difference between start and
end time fields
http://www.bizsupportonline.net/infopath2003/time-calculations-infopath-using-rules.htm
http://www.bizsupportonline.net/infopath2003/adding-time-calculating-differences.htm
 
D

danib37

Hi Anuma!

Thanks for helping me out with this. I need a bit more help, due to my form
code inexperience!

My form name is Time Counter. I've added 2 text boxes and named them
StartTime and EndTime (is that correct...should those be text boxes?) I also
added a button, called Button1, and added the code exactly as you typed:

Time = DateTime.Now.ToString("HH:mm:ss");
thisxdocument.SelectSingleNode("StartTime", Time).text;
StartTime --> Enter your start Time field xpath

When I copy and paste the code exactly as is and run, I get this message:

InfoPath cannot open the selected form because of an error in the form's code.
The following error occurred:

Expected ';'
File:script.js
Line:35
StartTime --> Enter your start Time field xpath

I'm assuming there are pieces of that code that I need to change to reflect
my form?

Thanks for your help!

Dani
 
A

Anuma(GGK Tech)

Hi,

I think you are using jscript. But I have given C# code.

Can you follow the below steps.
1. Double click on the button.
2. Click on Rules and Click on Add button.
3. Click on “Add Action†button.
4. Select “Set a Field Value†in first dropdown.
5. Select “Start Date†field in Field box.
6. Enter following formula in Value field.
substring-after(now(), "T")
7. Click on ok.
 
D

danib37

What data type should the "StartTime" field be?

Anuma(GGK Tech) said:
Hi,

I think you are using jscript. But I have given C# code.

Can you follow the below steps.
1. Double click on the button.
2. Click on Rules and Click on Add button.
3. Click on “Add Action†button.
4. Select “Set a Field Value†in first dropdown.
5. Select “Start Date†field in Field box.
6. Enter following formula in Value field.
substring-after(now(), "T")
7. Click on ok.
 

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