cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kharina
Helper V
Helper V

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
v-xida-msft
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
WarrenBelz
Super User
Super User

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.

 

v-xida-msft
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

kharina
Helper V
Helper V

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,551)