cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Marc_Gutzwiller
Helper I
Helper I

Repeating table and button

Hi all. 
I am creating a time sheet and would like the user to set the time with a "now" button. This is should be saved in a collection. Without the button it works fine. But with the button I have 3 problems:
1. It doesn't write the collection. 
2. if I push the button the update will be made for all the "START" labels.

3. after saving one can still push the button "NOW" on the first row and it does change the value...

Marc_Gutzwiller_1-1609960836506.png


Now Button -> Set(VarNow, Now())
Input text field "START" -> Text(VarNow, ShortTime24)

Save collection button ->

Patch(CollectionTagesrapport, ThisItem, {
ARBEITPAUSE: ArbeitPause.SelectedText.Value,
STARTZEIT: Value(Start_Zeit.Text),
ENDZEIT: Value(End_Zeit.Text),
TOTALZEIT: Value(Total_Zeit.Text)}
)
;
Collect(CollectionTagesrapport, {
ARBEITPAUSE: "",
STARTZEIT: "",
ENDZEIT: "",
TOTALZEIT: ""}
);

 

 

Could anyone help me to figure this out? Maybe @RandyHayes - you allready helped me out with a similar topic...

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@Marc_Gutzwiller 

Sorry...we needed the full record to update.  Our Update function replaces old records with new records.  In this case we were providing a new record with just the start or end.  That was my mistake as I rarely use Update and typically use UpdateIf - which does update records with changes, not with new records.

 

Anyway...

Make these changes:

Start-Time-Button:
Patch(CollectionTagesrapport, ThisItem, {STARTZEIT: Text(Now(), ShortTime24)}); Reset(Start_Zeit)

End-Time: ThisItem.ENDZEIT
End-Time-Button:
Patch(CollectionTagesrapport, ThisItem, {ENDZEIT: Text(Now(), ShortTime24)}); Reset(End_Zeit)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@Marc_Gutzwiller 

The reason for this is because you are referencing a global variable and all of the Start input controls are set to get their value from that variable.

However, the solution is easier than you might think...

 

Change the formula on the Now Button to the following:

   Update(CollectionTagesrapport, ThisItem, {STARTZEIT: Text(Now(), ShortTime24)});
   Reset(StartInputControlNameHere)

 

Change the Default property of your StartInputControl to : 

   ThisItem.STARTZEIT

 

I hope this is helpful for you.

    

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 
Thank you very much again for you help and the explanations. I hope I will get grab oft that some day :-).  The button works fine and it also saves into the collection.


However when I add another button, alike the first one, for the End-Time, it deletes me the Start-Time when pressing the new Button (also in the cache...  is there something else to take into account? 


Thank you very much for helping me out! 

Marc_Gutzwiller_0-1610028974179.png

 




Start-Time: ThisItem.STARTZEIT
Start-Time-Button:
Update(CollectionTagesrapport, ThisItem, {STARTZEIT: Text(Now(), ShortTime24)}); Reset(Start_Zeit)

End-Time: ThisItem.ENDZEIT
End-Time-Button:
Update(CollectionTagesrapport, ThisItem, {ENDZEIT: Text(Now(), ShortTime24)}); Reset(End_Zeit)

SaveButton:
Patch(CollectionTagesrapport, ThisItem, {
ARBEITPAUSE: ArbeitPause.SelectedText.Value,
STARTZEIT: Start_Zeit.Text,
ENDZEIT: End_Zeit.Text,
TOTALZEIT: Value(Total_Zeit.Text)}
)
;
Collect(CollectionTagesrapport, {
ARBEITPAUSE: "",
STARTZEIT: "",
ENDZEIT: "",
TOTALZEIT: ""}
);




RandyHayes
Super User III
Super User III

@Marc_Gutzwiller 

Sorry...we needed the full record to update.  Our Update function replaces old records with new records.  In this case we were providing a new record with just the start or end.  That was my mistake as I rarely use Update and typically use UpdateIf - which does update records with changes, not with new records.

 

Anyway...

Make these changes:

Start-Time-Button:
Patch(CollectionTagesrapport, ThisItem, {STARTZEIT: Text(Now(), ShortTime24)}); Reset(Start_Zeit)

End-Time: ThisItem.ENDZEIT
End-Time-Button:
Patch(CollectionTagesrapport, ThisItem, {ENDZEIT: Text(Now(), ShortTime24)}); Reset(End_Zeit)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

@RandyHayes Thank you very much for sharing the solution - I would never got that without your help!

RandyHayes
Super User III
Super User III

@Marc_Gutzwiller 

Always happy to help!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (17,639)