web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / quantity update from d...
Power Apps
Unanswered

quantity update from data source to another data source using dropdown in a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have 2 data sources namely, try1 and Try 22 in ms lists,
I am having issues with deducting the quantity in try1 from Try22, it is like an inventory system where a user can log an item and then the quantity the user asked will be deducted from the datasource(try1), I used Try22 for logging an item while try1 are used for storing the items. It should be done by clicking a Save button to proceed. 

Here is my code for button On Select:

ForAll(
Filter(
Gallery2.AllItems,
Toggle3.Value = true
),
Patch( try1, First(Filter(try1, txtItemAdm.Text = Item )),
{
Quantity : LookUp(try1, Item = txtItemAdm.Text, Quantity) - Value(txtQtyLog.Text)
}
));

ForAll(
Filter(
Gallery2.AllItems,
Toggle3.Value = true
),
Patch(
Try22,
ThisRecord,
{
Title: lblLogID.Text,
Item: Dropdown1.SelectedText.Item,
Quantity: Value(txtQtyLog.Text),
Date: Value(DatePicker1.SelectedDate),
AssignedBy: Office365Users.MyProfileV2().displayName,
Assigned: ComboBox2.Selected.DisplayName
}
)
);


The issue in my code is that it is only updating the last record in the try1 datasource even if other item is selected from dropdown list.

Categories:
  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    Hi @Anonymous ,

    Please try this - I am assuming here you are using SharePoint (you did not specify your data source)

    ForAll(
     Filter(
     Gallery2.AllItems,
     Toggle3.Value
     ),
     With(
     {
     wRecord:
     LookUp(
     try1, 
     Item = txtItemAdm.Text
     )
     },
     Patch( 
     try1,
     {ID:wRecord.ID},
     {Quantity : wRecord.Quantity - Value(txtQtyLog.Text)}
     )
     )
    );
    Patch(
     Try22,
     ForAll(
     RenameColumns( 
     Filter(
     Gallery2.AllItems,
     Toggle3.Value
     ),
     "ID",
     "ID1"
     ),
     {
     ID:ID1, 
     Title: lblLogID.Text,
     Item: Dropdown1.SelectedText.Item,
     Quantity: Value(txtQtyLog.Text),
     Date: Value(DatePicker1.SelectedDate),
     AssignedBy: Office365Users.MyProfileV2().displayName,
     Assigned: ComboBox2.Selected.DisplayName
     }
     )
    )

     

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    yes, i used sharepoint list. by the way, does {ID.WRecord.ID} and {ID: aPatch.ID} required? because the error says invalid number of arguments: received 3, expected 2.

  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    @Anonymous ,

    Try it now

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz  I tried it but it has some errors, 

    error for try1 ds.pngerror for try2 ds.png

  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    @Anonymous ,

    Please try again and post your exact code in text if still not working - I have run it this end on a gallery and list with no errors. The code is valid providing your values are

    WarrenBelz_1-1650949178047.png

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I did it exactly the same way you did,

    ForAll(
    Filter(
    Gallery2.AllItems,
    Toggle3.Value
    ),
    With(
    {
    wRecord:
    LookUp(
    try1,
    txtItemAdm.Text = Item
    )
    }
    Patch(
    try1,
    {ID:wRecord.ID},
    {Quantity : wRecord.Quantity - Value(txtQtyLog.Text)}
    )
    )
    );
    Patch(
    Try22,
    ForAll(
    RenameColumns(
    Filter(
    Gallery2.AllItems,
    Toggle3.Value
    ),
    "ID",
    "ID1"
    ),
    {
    ID:ID1,
    Title: lblLogID.Text,
    Item: Dropdown1.SelectedText.Item,
    Quantity: Value(txtQtyLog.Text),
    Date: Value(DatePicker1.SelectedDate),
    AssignedBy: Office365Users.MyProfileV2().displayName,
    Assigned: ComboBox2.Selected.DisplayName
    }
    )
    )

    are there some values i should change?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz  there was no errors, but it is still the same, the only record that is updating are the last record from try1, it does not update the record that is selected from dropdown list

  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    @Anonymous ,

    You are missing a comma at the end of the first With() statement

  • WarrenBelz Profile Picture
    156,730 Most Valuable Professional on at

    @Anonymous ,

    There must be something wrong with your Lookup

    LookUp(
     try1,
     Item = txtItemAdm.Text
    )

    as this is the way you are finding the correct record to update

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    here is the code you asked a while ago

    code.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard