I building a custom form off a SharePoint list that has about 20 yes/no fields and a text field named Total Points. What I want to do is on the PowerApps form, use toggles for the Yes/No fields and set them up so that if the toggle is selected/yes, one point is added to Total Points. If a toggle is unselected/no, then one point is subtracted from the total.
I've tried to do this using a global variable and incrementing/decrementing it using the On Check and On Uncheck function on the toggle fields. So when the app opens the variable is set to 0, then if Toggle A is selected the On Check function uses the following to increment the variable:
Set(varPoints, varPoints+1)
If the user turns off the toggle, the On Uncheck formula is Set(varPoints, varPoints-1)
The Total Points field is getting updated as I expected. But when I edit an item when the form opens it's incrementing the Total Points without any action on my part, adding to it. It's as if the app is checking and sees that some toggles are selected and adding 1 for each one selected.
I'm trying to have the form open with the Total Points showing based on the number of toggles selected and not change unless a change is made to a toggle.
Thanks. Two questions:
The "DataCardValueN.Value" above refers to the name of the slider data cards?
In "Refresh(increments)" what does "increments" indicate, the slider data cards again?
Looks like there is a timing thing going on.
This is what i have done.
Insert a timer and set the value to may be 3000 milli seconds
on timer end Set(vartotals,Value(SharePointIntegration.Selected.Title))
Default for Totals Data card vartotals
SharePoint integration on save
Set(
vartotals,
0
);
If(
DataCardValue2.Value,
Set(
vartotals,
vartotals + 1
)
);
If(
DataCardValue3.Value,
Set(
vartotals,
vartotals + 1
)
);
If(
DataCardValue4.Value,
Set(
vartotals,
vartotals + 1
)
);
SubmitForm(SharePointForm1);
OnEdit, OnView,OnNew :Refresh(increments);
Hope this helps.
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
I thought I would provide more details. Here is how I have this app set up now, trying to follow you directions. The biggest problem at the moment is that when I create a new item, switching the toggle is not incrementing the Total Points field.
App
OnStart: Set(varID,SharePointIntegration.SelectedListItemID); Set(varPoints,0); Set(varSelected,SharePointIntegration.Selected.'Total Points');
SharePointIntegration
OnNew: NewForm(SharePointForm1);
OnSave: SubmitForm(SharePointForm1)
FormScreen1
OnVisible: Set(varPoints, Value(varSelected))
Total_Points_DataCard1
text input: DataCardValue15>Default: Parent.Default
Toggle control
OnChange: If(Self.Value,Set(varPoints,varPoints+1),Set(varPoints,varPoints-1))
So this is a SharePoint list customized form, and when they select New in SHarePoint I want to load the form, and not a gallery. Could you show how these variables and settings would work with a custom form that has the OnNew, OnSave, etc. settings? I appreciate your help. I'm just struggling to translate your solution to my custom form.
Please use this. This should work for you.
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
Let me take a look at it and give you a solution.
A little more analysis seems to reveal the following: the OnNew property for the app sets the varPoints variable to 0. But when I open a new item, it seems to be looking at the last item I added, turning off the toggles that were selected, and since those are essentially being unchecked, it's decrementing the start value. So, I create a new item, select 7 toggles so that the Totals is 7. Then if I open a new item in the list, the form appears with all the toggles deselected, but the Totals field is showing -7.
Still not able to edit an item and have the Totals field increment or decrement when toggles are checked or unchecked.
Thanks, Kranthi. You solution fixed the problem of the Total field automatically updating. The problem I'm having now is that when I edit an item that was added to the SharePoint list, if I select additional toggles, they are not incrementing the Total field. Also, when I add a new item, the Total field is not defaulting to 0.
For example: I add my first item to the list. Total field = 0. I select 4 toggles and Total field goes to 4. Save item. Then edit item and select additional toggles. Total remains at 4.
After adding the first item I add a new item to the list. On this item the Total field is defaulting to -4, not 0. Maybe there are issues with how the form is updating the list, resets that I need to consider, etc.?
Hi @Anonymous I tried to replicate your issue and it works perfectly fine for me.
If(Form1.Mode=FormMode.New,vartotal, Parent.Default) i used this on my totals text field.
I am also attaching my sample app here.
Using SP and all the fields are defaulted to No.
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
WarrenBelz
89
Most Valuable Professional
MS.Ragavendar
60
stampcoin
48