cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IPC_ahaas
Post Patron
Post Patron

Update SharePoint List via PowerApp Gallery to Form

Disclaimer: Learning a lot here and I've been modifying an app made by a previous employee. I'm go the point where I'm making fixes for things that weren't working.

 

The app I am working on is has a Gallery that displays Employees and Reward Points (Home Screen) from List 1.

I've got it so when you click a button for an item in the Gallery, it populates a Form with this data (Reward Exchange Screen). There are two dropdown menus to used to deduct Reward Points (for exchanging purposes). If an Employee has 10 Reward Points, and the dropdown is selected to 5, I want to UPDATE the SharePoint List to reflect that the Employee now only have 5 Reward Points. This is Part 1.

 

Part 2 is updating List 2, which acts as a log of Reward Points added (Employee Award Screen) and removed (Reward Exchange Screen).

 

Focusing on Part 1, I'm a little confused on how to properly have the form update the specific record from the SharePoint List. The app is currently using "SubmitForm" but that seems to be creating duplicate records. I found some threads saying to use "Patch", but when I use OnSelect = "Patch(List1,ThisItem.ID,{Quantity: LblRewardDifference.Value);" it says there is an error in the formula.

 

For reference, I pull the existing Reward Points value as VarRewardQuantity then use DrpRewardExchangeAmount to select how many Reward Points to deduct. How many Reward Points they'll have left is displayed in LblRewardDifference so I figured it would be simplest to use that rather than do the math a second time.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

HI @IPC_ahaas ,

Try this

Patch(
   List1,
   {ID: ThisItem.ID},
   {Quantity: Value(LblRewardDifference.Text)}
)

 

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.

Visit my blog Practical Power Apps

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

HI @IPC_ahaas ,

Try this

Patch(
   List1,
   {ID: ThisItem.ID},
   {Quantity: Value(LblRewardDifference.Text)}
)

 

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.

Visit my blog Practical Power Apps

rohitsbots
Resolver II
Resolver II

Use this Patch( List1, ID= ThisItem.ID, {Quantity: Value(LblRewardDifference.Text)} )

IPC_ahaas
Post Patron
Post Patron

@WarrenBelz @rohitsbots 

 

Both of those scripts fail with "Expected text or number. We expect text or a number at this point in the formula. The error will occur if you use a function that requires either text or a number but you supply, for example, a boolean (true/false) value."

 

I'm at a loss for why it's not working.

IPC_ahaas
Post Patron
Post Patron

I'm wondering if the error is with the "ID". It says "Name isn't valid. 'ID' not recognized." On the "Home" Scene I'm displaying "ThisItem.ID", so it clearly exists. I am passing that value as "VarTargetID" to the "Reward Exchange" Screen. The error isn't on how I call it ("ThisItem.ID" or "VarTargetID") it's on the actual "ID" specifier. I don't get how it cannot find it if I'm using it.

IPC_ahaas
Post Patron
Post Patron

Sorry for the tipple post, I think I figured it out:

 

Patch(List1,{ID: VarTargetID},{Quantity: Value(LblRewardDifferenceExchange.Text)})

 

I had to use @WarrenBelz 's format but use the variable "VarTargetID" that I'm passing from the "Home" Screen rather than "ThisItem.ID".

IPC_ahaas
Post Patron
Post Patron

@WarrenBelz Since this is using "Patch", does it even need to be a Form? Or is a Form only for creating new data in a List?

@IPC_ahaas ,

No - if you have the ID as a Variable (I only used ThisItem.ID as you did in your post), then you can get the Quantity as the Value of any Text Input and Patch it (you do not need a Form).

 

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.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

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

Users online (1,783)