cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
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.
Highlighted

@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
Highlighted

@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
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 (9,806)