cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DavidLozzi
Advocate II
Advocate II

variable not being set properly

I have a basic Edit Form, with several checkboxes. I am counting each time they are checked or unchecked, like:

 

UpdateContext({TotalDone:TotalDone+1})

and

UpdateContext({TotalDone:TotalDone-1})

I am displaying the total done on the form itself (NumberPledged is a Collection value)

TotalDone & "/" & First(NumberPledged).Value

On the form, this works and users can see 3/10 or 10/10.

When they press the submit button, I am attempting to write this data to a Slack channel

SubmitForm(EditForm1); Slack.PostMessage("my_test",User().FullName & " just logged " & TotalDone & " out of " & First(NumberPledged).Value & " activities! Give 'em a high five!")

Which posts, but the numbers aren't always accurate. When selecting all items on the form, my first post to Slack was 3 out of 10, then I did it again and got 10 out of 10. I just tried again, selected 4 and slack shows 7 out of 10. 

 

I do clear the variable onvisible of the edit form to reset it

UpdateContext({TotalDone:0})

I don't know what else to do here.

Lozzi
slalom
4 REPLIES 4
hpkeong
Community Champion
Community Champion

Hi

 

I may not be really understanding what is Slack.PostMessage  (...) (a MS Flow?).

Anyway, I guess they might be something to do with:

UpdateContext({TotalDone:0})

 

I would propose to write like thiss;

UpdateContext({TotalDone:1}); UpdateContext({TotalDone:0})

Reason:

UpdateContext always works in PAIR.

The first UpdateContext can be of any value but the Second UpdateContext will be the FINAL updated value.

 

May you try?

 

Hope it workd and have a nice day.

hpkeong
v-micsh-msft
Community Support
Community Support

Hi @DavidLozzi,

 

"I do clear the variable onvisible of the edit form to reset it", would you please explain a bit for this?

Which control's property that you configured the "

UpdateContext({TotalDone:0})

"

With?

In addition, did the variable display well before submiting the editform?

 

Please take try to add the Updatecontext({TotalDone:0}) at the end of the submit button onselect property, see if this would make it right .

SubmitForm(EditForm1); 
Slack.PostMessage("my_test",User().FullName & " just logged " & TotalDone & " out of " & First(NumberPledged).Value & " activities! Give 'em a high five!");
Updatecontext({TotalDone:0})

 If this is still not working, would you please share a screenshot for further investigation?

 

@hpkeong, I think Slack.PostMessage is a function for Slack connection under PowerApps, currently there is no corresponding documentation published, but it is listed under the connection list.

 

 

Regards

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-micsh-msft

I am setting 

UpdateContext({TotalDone:0})

on the OnVisible of the form.

I tried adding the above to the end of the submit button, but alas i checked off 3 items and it said 5 items

 

Each toggle has the same OnCheck and OnUncheck

 

2017-04-03_8-36-13.png

 

 

 FYI the blue 'i' is a result of the author email property:2017-04-03_8-39-18.png

 

 

 

 

 

 

Lozzi
slalom

@hpkeong I can't just set the TotalDone to 1 or 0, since I want a count of total toggles checked. See my other reply with a screen shot.

Lozzi
slalom

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,818)