Link to home
Start Free TrialLog in
Avatar of cadlkid
cadlkid

asked on

Auto Increment Time in Repeating Table

I have a repeating table in my form.  When someone adds a new row I would like the form to automatically increment the "time" column field by 1/2 hour.  I have spent many hours on this, can anyone help?

Thank you.
Avatar of Clay Fox
Clay Fox
Flag of United States of America image

If you are using InfoPath 2010 or 2013, there is an addSeconds() function.  You can take the previous record or now() or whatever and add 1800 seconds to it.

Another method is to use substring functions to break out the hour and minutes and manually calculate but that is more complex to pull off.
Avatar of cadlkid
cadlkid

ASKER

Thank you for your quick response

I had just figured out how to add 1800 seconds to the "Time" field.  I then created a rule on the time field so that when a value changes it updates a variable to hold the new time that has been updated by 1/2 hour.  This works perfectly inside of Infopath but when I publish to my Sharepoint Form Library and open it inside of a browser, the time only gets update one time.  If I click the "close form" button and then immediatly cancel the dialog box, the repeating table then updates itself with all of correct times that have been updated by 1/2 hour.  Any ideas?
I would trigger the update in a different location probably.  Maybe a button or something else that is getting clicked each time if that is available.  Could even check and just make sure it is updated as a fail safe.

You can also specify in the browser properties how often it updates values. "postbacks"
Avatar of cadlkid

ASKER

Here is screen shot inside of Infopath Application
inside-infopath.JPG
Avatar of cadlkid

ASKER

Inside of browser screen shot
inside-browser.jpg
I would probably have the rule and action on the insert, in the field default values.  I think that is the simplest.
Avatar of cadlkid

ASKER

Thanks Clay.  Unfortunately I don't understand exactly where you suggest me putting the rule.  Can you explain a little more in depth?  sorry.
ASKER CERTIFIED SOLUTION
Avatar of Clay Fox
Clay Fox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cadlkid

ASKER

Hi Clay, me again.  What do you mean be "default on the external field"?  are you talking about a data source from a sharepoint library with the starting time that I want?
You said you had another "variable" field which was updated by time.

That is where you store the next time I assume.
Avatar of cadlkid

ASKER

OK, I finally got it working.  Clay, your advice was spot on.  Here are the steps I did following Clay's advice for anyone else who is interested in increasing the time for a repeating table at certain intervals (in my case every 1/2 hour)

1.  Start simple, add a 1 column repeating table to your form,
• name the field "Time"
• set it's datatype to "Time"
2.  add (2) text boxes to your form (but delete both right away so they are hidden)
• Name one of them "Add1800Seconds" - datatype "Whole Number"  default value of 1800
• Name the other one "TimeHolder" - datatype of "Time" - dafult value is the starting time you want (in my case it was 09:00:00 AM)

3.  Click on the repeating table to highlight it.  Add a rule to it....
• "Rule runs when field changes"
• Action "Set a field's value"
• Field "TimeHolder"
• Value "addseconds(TimeHolder, Add1800Seconds)

4.  Right click the repeating table, goto properties, edit default values
• Check "Time", set defeault value to "TimeHolder"
• Uncheck the "Refresh value when formula is recalculated" box
Avatar of cadlkid

ASKER

super fast response time!