cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Use one button for Start and End record

Hi All, 

 

Hope everyone is well.

 

I created a post about this issue but I think I described it wrong: (that's why I never get a solution)

Single-button-with-a-toggle-different-record 


So  I'm sorry if I created a new topic. 

I just want to use one single button start and end a session. 

I am currently using 2 bottons, 1 start-button and 1 end-button.

Is this possible - to use just one button ?

 

Thank you all in advance,

Kharina

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @kharina ,

Do you want to collect a single one record once time when you press the "Save" button?

 

Based on the needs that you mentioned, I think the solution provided in your previous reply could achieve your needs. I have made a test on my side, please check the following screenshot:

4.JPG

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

UpdateContext({IsStart: !IsStart});
If(
    IsStart = true,
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1.Text}),
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1_1.Text})
)

or

Set(IsStart, !IsStart); 
If(
    IsStart = true,
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1.Text}),
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1_1.Text})
)

Set the Items property of the Data Table to following:

Stamp

Please check the following GIF screenshot for more details:

Test.gif

 

Based on the screenshot you listed in your previous thread, I think there is something wrong with your Collect formula. Within the "Start", "End" and "Toggle" button, you collect a collection (called "Stamp") contains "TimeStamp" and "Description" column. But within your "Save" button, you collect a collection called "stamp" collection contains "timestamp" and "Description" column. The "Stamp" and the "stamp" collection are different collections rather than same one.

Note: The variable name is case-sensitive in PowerApps canvas app.

But according to the Data Table screenshot that you mentioned in previous thread, it seems to be connected to "Stamp" collection rather than "stamp" collection. So please change the Items property of the Data Table control from "Stamp" into "stamp", then enable corresponding fields within this Data Table, check if the issue is solved. Or you could modify the formula within your "Save" button to following:

UpdateContext({Save: !Save});
If(
    Save = true,
    Collect(Stamp, {TimeStamp: Label5_4.Text, Description: Button4.Text}),
    Collect(Stamp, {TimeStamp: Label5_4.Text, Description: Button4_1.Text})
)

 

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.

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Hi @kharina ,

Set a Variable - the first time it will start and set it, the second time it will be true and end the session.

If(
   !vStarted,
   UpdateContext({vStarted:true});
   YourStartCode,
   YourEndCode
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Highlighted
Community Support
Community Support

Hi @kharina ,

Do you want to collect a single one record once time when you press the "Save" button?

 

Based on the needs that you mentioned, I think the solution provided in your previous reply could achieve your needs. I have made a test on my side, please check the following screenshot:

4.JPG

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

UpdateContext({IsStart: !IsStart});
If(
    IsStart = true,
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1.Text}),
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1_1.Text})
)

or

Set(IsStart, !IsStart); 
If(
    IsStart = true,
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1.Text}),
    Collect(Stamp, {TimeStamp: Text(Now(), "[$-en-US]yyyy-mm-dd HH:mm:ss"), Description: Button1_1.Text})
)

Set the Items property of the Data Table to following:

Stamp

Please check the following GIF screenshot for more details:

Test.gif

 

Based on the screenshot you listed in your previous thread, I think there is something wrong with your Collect formula. Within the "Start", "End" and "Toggle" button, you collect a collection (called "Stamp") contains "TimeStamp" and "Description" column. But within your "Save" button, you collect a collection called "stamp" collection contains "timestamp" and "Description" column. The "Stamp" and the "stamp" collection are different collections rather than same one.

Note: The variable name is case-sensitive in PowerApps canvas app.

But according to the Data Table screenshot that you mentioned in previous thread, it seems to be connected to "Stamp" collection rather than "stamp" collection. So please change the Items property of the Data Table control from "Stamp" into "stamp", then enable corresponding fields within this Data Table, check if the issue is solved. Or you could modify the formula within your "Save" button to following:

UpdateContext({Save: !Save});
If(
    Save = true,
    Collect(Stamp, {TimeStamp: Label5_4.Text, Description: Button4.Text}),
    Collect(Stamp, {TimeStamp: Label5_4.Text, Description: Button4_1.Text})
)

 

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.

View solution in original post

Highlighted
Helper IV
Helper IV

Hi @v-xida-msft ,

 

I tried all of the solutions given to me by the 3 of you, when I look at the solution , it seems like all the replies from @WarrenBelz and you gave me the right solution. However when I tested all, this is the only one that gives me an output. 

 

kharina_0-1594711792814.png

The other formula gives me no error but there's no record (or output )  inside my Data Table. 

 

So thank you both, Warren, Eka and Kris. I really appreciate all of you.

 

Kind Regards,

Kharina

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,470)