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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,374)