web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use one button for Sta...
Power Apps
Answered

Use one button for Start and End record

(0) ShareShare
ReportReport
Posted on by 249

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

 

Categories:
  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    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.

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

  • kharina Profile Picture
    249 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard