cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Pate1410
Level: Powered On

Get Value from a DropDown and save to a SharePoint list

Hi!

I'm new in developing in PowerApps and struggling with a drop-down function.

I created a time tracking app:



The two dropdowns get their data both from different SharePoint lists. I set it up that when a user presses the start/stop Button, the timer starts/stops.



When he hits the Reset Record Button, the time gets tracked into the list on the right and all dropdowns and the timer get back to default.

So far everything works fine but I cat get the rest together: What I want to do now:

1. Add the values (based on what item from the list a user chooses) of the dropdowns in the list when a user hits the RR Button. So a list entry should look like this:
___________________________
FirstDropdown
SecondDropdown
Time
___________________________

2. Save the results to a new line in a SharePoint list whenever the RR Button was pressed:

FirstDropdown | SecondDropdown | Time | User | Time rounded to full 15 minutes |

Any help is more than welcome! Thanks in advance.

1.JPG

2.JPG

 

6 REPLIES 6
rebeccas
Level 10

Re: Get Value from a DropDown and save to a SharePoint list

The same way you are putting- Time: Timer1.Text

behind it put a comma and then ColumnName: DropDown1.Selected.Value for each and it will store the drop down selections in the same manner.

Community Support Team
Community Support Team

Re: Get Value from a DropDown and save to a SharePoint list

Hi @Pate1410 ,

Do you want to patch the two Dropdown selected values, Timer values and current login user into your SP list whenever you press the RR Button?

 

Based on the needs that you mentioned, I think the Patch function could achieve your needs. I have made a test on my side, please take a try with the following workaround:

The data structure of my SP list:2.JPG

The App's configuration as below:3.JPG

 

4.JPG

 

5.JPG

Set the Duration property of the Timer control (Timer1) to following:

 

60000*10

Set the Start properyt of the Timer control to following:

 

 

IsStart

 

Set the OnSelect property of the "Start" button to following:

 

UpdateContext({IsStart: true})

Set the OnSelect property of the "Stop" button to following:

 

 

UpdateContext({IsStart: false})

Set the OnSelect property of the "Reset & Recod" button to following:

 

 

Patch(
       '20190306_case3',   /* <-- '20190306_case3' represents my SP list */
        Defaults('20190306_case3'), 
        {
Title: "Time Track Record", FirstDropdown: Dropdown1.Selected.Value, SecondDropdown: Dropdown2.Selected.Value, Time: Timer1.Value/1000, User: User().FullName, 'Time rounded to full 15 minutes': Round((Timer1.Value/60000)/15,0) } ); Reset(Timer1); Reset(Dropdown1); Reset(Dropdown2); UpdateContext({IsStart:false})

On your side, you should type:

Patch(
       'YourSPList',   /* <-- '20190306_case3' represents my SP list */
        Defaults('YourSPList'), 
        {
Title: "Time Track Record", FirstDropdown: YourFirstDropdown.Selected.Value, SecondDropdown: YourSecondDropdown.Selected.Value, Time: Timer1.Value/1000, /* <-- You could also consider capture the Timer1 value using Timer1.Text formula (that you mentioned)*/ User: User().FullName, 'Time rounded to full 15 minutes': Round((Timer1.Value/60000)/15,0) } ); Reset(Timer1); Reset(Dropdown1); Reset(Dropdown2); UpdateContext({IsStart:false})

Or

Patch(
       'YourSPList',   /* <-- '20190306_case3' represents my SP list */
        Defaults('YourSPList'), 
        {
Title: "Time Track Record", FirstDropdown: YourFirstDropdown.Selected.Value, SecondDropdown: YourSecondDropdown.Selected.Value, Time: Timer1.Text, User: User().FullName, 'Time rounded to full 15 minutes': Round((Timer1.Value/60000)/15,0) } ); Reset(Timer1); Reset(Dropdown1); Reset(Dropdown2); UpdateContext({IsStart:false})

Please check the attached GIF screenshot for more details:

 

More details about Patch function, please check the following article:

Patch function

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Pate1410
Level: Powered On

Re: Get Value from a DropDown and save to a SharePoint list

Amazing, I could actually make it work until the time rounded expression: I guess there had to be some more change on my side as I'm in Europe and have to change some "," to ; and ";" to ";;".

 

As I tested the app without the rounding function I ran into another problem: The timer stops counting when a user switches the Browser Tab. As I found out within some research there is actually no function to make it work at the moment continuing the counting in the background.

 

So I guess I need to change the app a bit:

 

Click "Start Button": get the time stamp on when the button is clicked

Click "Stop Botton": get the time stamp on when the button is clicked

Add a new field that calculates the summary of the time rounded to 15 Minutes after the "Stop Button" was pressed 

Click "Reset & Record": Send all data to the Sharepoint list.

 

Here my Idea, that did not work out so far:

 

Created three text input fields:

 

1 - "TimeStart"

2 - "TimeStop"

3- "Summary"

 

where the timestamps should be inserted after clicking the start and stop button ("TimeStart" and "TimeStop") as well as the total time rounded should be calculated ("Summary").

 

Start Button on select : 

UpdateContext(TimeStart); Text( Now(), "mm/dd/yyyy hh:mm:ss" )

Stop Button on select : 

UpdateContext(TimeStop); Text( Now(), "mm/dd/yyyy hh:mm:ss" )

then:

 

SumRounded(DateTimeValue(TimeStart.Text),DateTimeValue(TimeStop.Text))

after all then via patch:

Patch( Zeiterfassung; Defaults(Zeiterfassung);{Projekt: Dropdown1.Selected.Value; Leistungsbild: Dropdown2.Selected.Value; Detailbeschreibung: BeschreibungInput.Text;  Start: TimeStart.Text; Stop: TimeStop.Text; TimeRounded: SumRounded.Text; User: User().FullName});; Reset(TimeStart);; Reset(TimeStop);; Reset(SumRounded);; Reset(Dropdown1);; Reset(Dropdown2);; Reset(BeschreibungInput);; UpdateContext({IsStart:false})

I'm confused!? Any ideas here? Working with the German Version here.

rebeccas
Level 10

Re: Get Value from a DropDown and save to a SharePoint list

For just a small piece of you issue..I have one app that is a "Time Clock" that captures time and mine does a little different but I have tried it a few ways and found this way to work best:

 

Screen OnVisible= Set(_CurrentTime,Now())

 

Timer-

AutStart = true

Duratuion =1000

OnTImerEnd = Set(_CurrentTime,Now())

Repeat = true

Reset = false

Text(Time(0,0, Timer1.Value/1000), "hh:mm:ss")

 

Label- (not required but I like it)

Text= Text(_CurrentTime,LongTime24)

 

What this does is collect the current time when you get to the screen as a Variable and the timer adds another second to that variable for every second that passes so the variable of "__CurrentTime" is always the actual current time. 

 

Otherwise I found that it is in accurate in a lot of ways. This one works great for me and formats the time well too.

 

 

 

 

 

 

Pate1410
Level: Powered On

Re: Get Value from a DropDown and save to a SharePoint list

Thanks for the tip.

 

What I did now, and what seems to be a good solution is:

 

I created two buttons Start/Stop to get their timestamps.

 

Start Button on Select:

Set(CurrentTimeStart;Now())

Stop Button on Select:

Set(CurrentTimeEnd;Now())

 

Then I created two text input fields for each Button record:

 

Start

Text(CurrentTimeStart; DateTimeFormat.ShortDateTime24)

End

Text(CurrentTimeEnd; DateTimeFormat.ShortDateTime24)

 

Working good so far!

 

So what I want to do now and what's not working so far is:

 

Calculate the time between Start and Stop and Display it in another text field:

missing expression for that

Send all to a Sharepoint list and reset all fields to be empty (works so far except of the Time fields, they get not emptied for some reason)

 

Patch( Zeiterfassung; Defaults(Zeiterfassung);{Projekt: Dropdown1.Selected.Value; Leistungsbild: Dropdown2.Selected.Value; Detailbeschreibung: BeschreibungInput.Text; Start: Start_time.Text; Ende: End_time.Text; Timer: Summe.Text; User: User().FullName});; Reset(Start_time);; Reset(End_time);; Reset(Dropdown1);; Reset(Dropdown2);; Reset(BeschreibungInput)

 

Close to a final result Smiley Happy Any help??

 

Unbenannt.PNG

 

 

rebeccas
Level 10

Re: Get Value from a DropDown and save to a SharePoint list

Double check (if you haven't already) that it is getting your time correctly like that. I can't remember exactly but I think I did that first and changed it because "Now()" stores the time that you opened the app or got to the screen I believe and doesn't take into account if they let the screen sit open. If you don't have users that will do that then it won't be an issue.

 

You can get the time between your start and stop by using "DateDiff". I did not choose that option, I did my as a calculated field in SharePoint instead because if you use DateDiff it will capture it at that moment and not recalculate if you have to do a time correction at some point....which again, you may not need but I did.