cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Smudgers91919
New Member

Stop Watch App with split timer

I'm trying to create a method of recording time spent using an App that has a start and stop button.  When Start is pressed it logs the Now() time in a SharePoint list column called Start1.  When Stop is pressed it logs the Now() time in another column on that list called Stop1. 
I want to be able to record multiple start/stop times using the same buttons.  So when Start is pressed once, log time to column Start1, but if Start1 has a value and the button is pressed again it will add the Now() entry to Start2 column and so on.  Is this possible as I can't seem to work it out?

48 REPLIES 48

Correct, every column has unique information.

JR-BejeweledOne
Super User
Super User

Ok, drop a label on the screen and set it to varTitle.   Let's make sure that it's actually getting set to the selected title each time.  Otherwise it will only look at the first item or whichever item matches the title in varTitle



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

So I already have some labels on screen to test this.  The Title is correct every time using the BGallery.Selected.Title.  The Current label (using BGallery.Selected.Current) does show the Current value for the row that's been selected, however the only reason it shows a 3 in this example, is because I changed the Current for the first row of data to 2 and when I pressed Stop it updated the Stop3 column on row 2 and entered 3 in the Current column for row 2.  
Labels.jpg

It appears the .current is only referencing the 1st row of data in my SharePoint list.

JR-BejeweledOne
Super User
Super User

If(LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 0,

 

I am going to presume that you are setting varTitle when an item in BGallery is selected.  so try changing the above formula.   Again my apologies, I should have known better than to leave the BGallery.Selected in there.

 

If(LookUp('Exec Support', Title = varTitle).Current = 0,

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Yes the varTitle is created at a button press when selecting a job.  Let me try to give you a bigger picture as I think we're so close but perhaps need a bit more context.

 

I have a separate App that our Exec group will use to submit a request for assistance.  This is recorded in a SharePoint list (Exec Support).  The columns are listed below and what they contain.

Title - Unique reference made up of the submitters username and the date e.g. ptspasa svc-141643 (submitted by my service account)

Current - Used to record the current stop interation

Submitted - Date and time the request was submitted

Request - Details of their request

Technician - The tech who is going to pick this job up

Start, Start2, Start 3, Start 4 - Recorded start times

Stop, Stop2, Stop3, Stop4 - Recorded stop times

Completed - Yes/No to mark as completed

 

Once the job is submitted from this App, the techs can use the App we have been working on to view any requests that have come through, pick them up and start marking their time against them by using the Start/Stop buttons.

The jobs are presented in a gallery in this app using the Sharepoint list as the datasource.

 

In the gallery the techs can select an item and press a button called Details which loads the form on another page, this button also creates varTitle using BGallery.Selected.Tile.

 

In the Form viewer we can see all of the job details and now have the Start and Stop and Completed buttons.  It's here I want to be able to press Start when they start doing some work, then press Stop when that has finished.  They have the ability to do this multiple times as it will record it in multiple columns until the work is completed.

 

What we have created is working by using 

       If(LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 0,
     Patch('Exec Support', BGallery.Selected,
           {
              Start: Now(),
              Technician: User().FullName
            }
          ),
       LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 1,
     Patch('Exec Support', BGallery.Selected,
           {
              Start2: Now()
            }
          ), 
       LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 2,
     Patch('Exec Support', BGallery.Selected,
           {
              Start3: Now()
            }
          ),
       LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 3,
     Patch('Exec Support', BGallery.Selected,
           {
              Start4: Now()
             }
          ))

But this only works for the first job in the gallery which is the first line of the SP List.

When selecting another job it doesn't record the start time on that line but does record the Stop time but only when the Current is less than 4 in the 1st line of the list.  So it looks as though 

       If(LookUp('Exec Support', BGallery.Selected.Title = varTitle).Current = 0,

Is correct where BGallery.Selected.Title is concerned but seems .Current only appears to look at the current column in the 1st line of my datasource.

 

Hope this makes more sense.

It's because you are comparing the Bgallery.Selected.Title. to varTitle and not comparing the Title of the item in the SharePoint list as I pointed out in my last post.

 

Since you are recording directly to the SharePoint list, you have to compare the title from 'Exec Support' either to varTitle or to BGallery.Selected.Title.

 

So either:

 

If(LookUp('Exec Support', Title = BGallery.Selected.Title).Current = 0,

 

Or

 

If(LookUp('Exec Support', Title = varTitle).Current = 0,


If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Apologies for the delay responding, I got pulled onto something different for a few days.

 

Great this works, I made the mistake and had updated some lines to match the above but not all of them so completely my fault.

 

The Start button is working as expected now thank you.  To throw another spanner in the works though is the Stop formula works unless you press the Stop button out of sequence it will keep updating Stop times because it is just looking at the value in the Current column but if this is changed incrementally each time you press Stop, it doesn't matter if there has been a Start time recorded.  I think what is needed is an IsBlank section to look for the corresponding Start value and if blank update but if not do nothing.  What do you think?

JR-BejeweledOne
Super User
Super User

This is going to look strange because it's somewhat different from the Start button formula.   It's because of how LookUp works in an If statement.   You might need to update the Title = since I don't know if you are comparing it to varTitle or BGallery.Selected.Title

 

LookUp returns a row of data.  In the start formula we took the row returned by the LookUp and told it to validate against the Current column in that row.

 

If(LookUp('Exec Support', Title = varTitle).Current = 0,

 

 In this new formula we are needing to validate 4 items.   The Title, the Current value and if the matching start and stop columns are blank or not.   We could make this much simpler if we used a First(Filter formula in the IF statement, but that gets time consuming after your list starts getting more and more data.   Let me know if you are interested in seeing how that formula looks.

 

If(LookUp('Exec Support', Title = varTitle && !IsBlank(Start) && IsBlank(Stop), Current) = 0 ,
     Patch('Exec Support', BGallery.Selected,
           {
              Stop: Now(),
              Technician: User().FullName,
              Current: 1
            }
          ),
       LookUp('Exec Support', Title = varTitle && !IsBlank(Start2) && IsBlank(Stop2), Current) = 1,
     Patch('Exec Support', BGallery.Selected,
           {
              Stop2: Now(),
              Current: 2
            }
          ), 
       LookUp('Exec Support', Title = varTitle && !IsBlank(Start3) && IsBlank(Stop3), Current) = 2,
     Patch('Exec Support', BGallery.Selected,
           {
              Stop3: Now(),
              Current: 3
            }
          ),
       LookUp('Exec Support', Title = varTitle && !IsBlank(Start4) && IsBlank(Stop4), Current) = 3,
     Patch('Exec Support', BGallery.Selected,
           {
              Stop4: Now(),
              Current: 4
            }
          ))

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Works a treat, thanks again for all the effort you put into this.  I just struggle getting my head around the different syntax.  The App is looking good now though.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,061)