Hello Team,
I'm stuck here and need aid from the community.
I have three text fields: StartTime, EndTime, and TotalTimeSpend.
I'm referring to form as form1.
When I select the status field as Production, Break, or any entry, I want the Starttime to take the current date and time, and when I submitform(form1), it should get the End date and time, as well as the total time spent in HH:MM:SS:
Starttime= DataCardValue5
Endtime = DataCardValue6
TotalTimeSpend= DataCardValue7
Data is storing in Sharepoint List name TimeTracker.
When you reference a Time function in your formula, it is evaluated when it first appears. It will not update itself as the time changes. So, you will need to keep track of the time in your app.
The best way to go about that is to place a Timer control in your app and set it not visible. Set the AutoStart to true and the repeat to true and the duration to 1000.
In the OnTimerEnd action of the timer, place the following formula: Set(glbCurrentTime, Now())
Now, in your formulas that you want to be based on current time, use the above variable instead of Now().
So, for your default formula, set it just to glbCurrentTime
By the way - Now() returns the date and time, so there is no need to do Today() + a time conversion based on the Hour minute and second, like you showed in your formula. Now() is equivalent. And with the above formula, glbCurrentTime is always Now() accurately updating.
I hope this is helpful for you.
Thanks a ton
Its working for StartTime but what do i need to put on EndTime and when i click the Save button it should store the date and time too. How its going to capture the time diff in the TotalTimeSpend
Well, the rest of it is all logic in your form.
For example, I am going to only assume that the Start time only gets filled in if the Production status is chosen. But, then you have a break time status and then what happens?
Are you creating individual records for each action (production, break, end, etc)? Or are you updating ONE record as the status changes? If that is the case, then you need logic in the form to preserve start time once entered, and then how does break time get accounted for?
If you are doing an individual record for each action, then the calculation would be based on the StartTime and the EndTime only.
So, not sure what your logic is in the app.
Creating an individual records for each action (production, break, end, etc)? Yes am updating ONE record as the status changes. that is the case and i need logic in the form to preserve start time once entered.
Doing an individual record for each action, the calculation would be based on the StartTime and the EndTime only.
Now what would be the logic here.
So your default for the StartTime would be (note, since you're storing as text, we need to convert for it):
Coalesce(Parent.Default, Text(glbCurrentTime))
That will preserve the start time.
What triggers an End time? I believe that is where the issue comes in.
When I click the Save button then only the EndTime trigger and the totaltimespend will trigger. And then form need to be reset for new entry
So if EndTime is getting set on save, then just set the Default of the End time to be the same as the starttime.
Coalesce(Parent.Default, Text(glbCurrentTime))
Your TotalTime would just be a DateDiff statement on the start and end times.
ex. DateDiff(DateTimeValue(yourStartTimeInput.Text), DateTimeValue(yourEndTimeInput.Text), Minutes)
But you had originally stated that the Status chosen somehow impacted your recording of the values, so I'm not sure how that is fitting in to the logic.
User | Count |
---|---|
126 | |
87 | |
84 | |
75 | |
69 |
User | Count |
---|---|
214 | |
178 | |
139 | |
105 | |
83 |