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
Solved! Go to Solution.
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:
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:
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,
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.
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:
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:
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,
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.
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
User | Count |
---|---|
253 | |
248 | |
82 | |
45 | |
28 |
User | Count |
---|---|
344 | |
260 | |
123 | |
60 | |
58 |