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

Copy data from a timer into data card

I added a timer feature to my app and I want to have a button available that when pressed, will copy the timer data and input it into a datacard of my choosing. When the "Record Pour" button is selected, I'd like the timer data to be copied into the "Pour Time" field. Is this possible?

 

Thank you

 

8 REPLIES 8
samuelJ
Level 8

Re: Copy data from a timer into data card

In Powerapps, in order to change the value of a property at run time, you need to use variables.  From my understanding a "Datacard" is a generic group of objects in a form, so I will assume for this problem, the object you want to set as the time is a label object.  

 

1. Set the text property of the label to be your variable.

 

2. In the buttons onClick property, you then need to set the variables value to the current time:

Set(myVariableName, myTimer.Text)

Hope this helps.

 

Jensen
Level: Powered On

Re: Copy data from a timer into data card

I don't think that works quite right. Since this is a sharepoint list, theres several items within the list and they all have several inputs, including this pour time input. If I change that datacard field to a variable (lets call it RecordPour) and then change the button to set that variable, it changes the data for every item that I open in that screen. For example, if I open one item and set the time to 1 second, it will change that field. However, if I save that item and open another, that second item will also have the field set to 1 second. I hope that makes sense.

Community Support Team
Community Support Team

Re: Copy data from a timer into data card

Hi @Jensen,

I agree with @samuelJ's thought almost. I think the global variable could achieve your needs.

Based on the issue that you mentioned about the variable, I think you should clear/reset the global variable when you open a new item every time.

I have made a test on my side, please take a try with the following workaround:

Set the OnVisible property of the Edit/New screen which contains the form to following:

Set(TimerValue, Blank())

Set the Default property of the Text Input box within the Pour Time Data card to following:

TimerValue

Set the OnSelect property of the "Record Pour" button to following:

Set(TimerValue, Timer1.Text) /* <- Timer1 represents the Timer control within your app */

Best regards,

Kris

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.
Jensen
Level: Powered On

Re: Copy data from a timer into data card

That's a little closer to what I was hoping to do. However, it does blank the value out so if you want to edit an item and not touch that field (which we will assume is already populated in this scenario), it will be erased. Is there any way around that?

samuelJ
Level 8

Re: Copy data from a timer into data card

I am not quite understanding the issue.  Based on the original post, my understanding is that there was a form with ONE field we wanted populated with a timer value.  My assumption was also that these values were populating a form, which would then be updated in a database later, as the value will not be retained through app sessions.  If these assumptions are wrong, the above solution is not correct.   So, the real problem to solve is you want to populate multiple values with different times, essentially like the "Lap" feature on a timer

 

If you have X objects you want to set to the current time when pushing a button, you need X variables.  You then need a way to determine what variable the current lap should be assigned to.  There are a few ways to do this. 

1.  Have multiple buttons, that each set a different variables times, this is propably the easiest solution but not most elegant if you have many fields. 

2.  Have some way to determine which variable it is you want to set.  You could do this with the OnSelect property of the object you want to set.  You would need another global variables that changes when selecting the desired object:

Set(currentTimeSelection, 1)

Then in the code I suggested before you would need to determine which variable you are using. 

If(currentTimeSelection = 1, Set(myVariableName1, myTimer.Text), If(currentTimeSelection = 2, Set(myVariableName2, myTimer.Text, //etc code for each variable needed)))

 

There are other ways to implement this, it comes down to what you want to implement.  If none of these sound right, perhaps provide more insight into what your app looks like and how exactly you want the flow of your app, how is it intended to be used. 

Jensen
Level: Powered On

Re: Copy data from a timer into data card

Your original assumption was correct, there is one field that we want populated with a timer value. @v-xida-msft's solution was closer to what I was trying to achieve, but created another problem that needs to be tackled. Here's the scenario:

1) The edit form is opened and a blank field needs to be populated with a timer value

2) The timer value populates the field with the button that we added earlier

3) The form is now saved.

4) The form is opened again for editing a different field

5) The field that we populated with a timer value is now blanked out due to the OnVisible formula added above (Set(TimerValue, Blank()).

 

I tried changing the OnVisible formula to OnSelect for the data field I'm editing, which solved that issue but created a new one. If the app is opened and the form is edited, it appears to default that variable to blank, but if I tried to edit a form, save, and then edit another form without closing the app, the original saved data still shows). So it seems like this variable defaults to blank when the app is opened. Any ideas?

 

Appreciate all the help so far!

 

 

Highlighted
Administrator
Administrator

Re: Copy data from a timer into data card

Hi @samuelJ thanks for your help so far with this thread! Are you able to assist further based on the updated information provided?

 

@TopShelf-MSFT

samuelJ
Level 8

Re: Copy data from a timer into data card

Unfortunetly, the issue is not clear to me on what the OP is having.  If the issue persists, perhaps provide some screen shots for clarification.  

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 40 members 4,935 guests
Please welcome our newest community members: