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 / Getting other field va...
Power Apps
Suggested Answer

Getting other field value from selected item in dropdown

(1) ShareShare
ReportReport
Posted on by 17
Hi everyone-
 
I have a Canvas app that is letting a user add inventory items. When they select an item from the dropdown, I am setting a variable with the value from a field in the selected item. It never sets anything and when I save the form, it just overwrites the value (because it never returned anything!)
 
In the OnChange of the dropdown, this is my statement: Set(varQuantityOnHand, ItemDataCardValue.Selected.'On Hand')
 
I don't get any errors or squiggly lines, but it doesn't load the value of the field "On Hand" into the variable. It's just blank.
 
Can anyone tell me what I am doing wrong here?
 
Thank you.
Joe
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,960 Moderator on at
    Hi
     
    Lets separate things. 
     
    1) setting that variable will have no impact on submitting a form. It’s always going to take the value that is selected. 
     
    2) is the form in New or Edit mode?
    if it’s new then wouldn’t it be empty since you didn’t set the on hands yet? 
     
     
  • Suggested answer
    Nandit Profile Picture
    1,568 Moderator on at
     
    Usually this occurs when you are trying to display more than 2000 records in your DropDown control. Can you please share how many items there are and what's your items property?
     
    You can try a couple of things here. Add the following to your OnChange property to see if it is getting triggered. - 
    Set(varQuantityOnHand, ItemDataCardValue.Selected.'On Hand');
    Set(varTest, "Hello")
    If varTest variable shows "Hello" as its value then the OnChange is working. 
     
    Second thing you can try is using ItemDataCardValue.Selected instead of ItemDataCardValue.Selected.'On Hand'. You can then use varQuantityOnHand.Value in your Patch statement.
     
    Hope this helps. 
     
    Kind regards,
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
  • Joseph Markovich Profile Picture
    17 on at
    Thank you both for your responses and assistance. I had to step away from this for a bit and looking at it again today, I realized my error.
     
    Mike, it is a new form, but I am trying to get a value from an existing inventory item in another table. I figured out what I was doing wrong.
     
    Nandit, thanks for reminding me to troubleshoot the update on the form field. I did that and it was setting the test variable just fine. So, after looking at all of the code in my Save button, I was somehow overwriting the number in the varQuantityOnHand variable I was setting.
     
    Here's the OnChange code for when the user selects an item in the drop-down:
     
    Set(varQuantityOnHand, ItemDataCardValue.Selected.'On Hand');
     
    And all of the code once they hit Save:
     
    If(IsBlank(ItemDataCard),
        //item does not exist, create the item
        Set(varItem, Patch(Items, Defaults(Items), { 'Item Number': NewItemDataCardValue.Text, 'On Hand': Value(QuantityReceivedValue.Text) } ));
     
        //create the receipt for the new item
        Set(varReceipt, Patch('Item Receipts', Defaults('Item Receipts'), { Item: varItem, Location: LocationDataCardValue.Selected, Cabinet: CabinetDataCardValue.Selected, Bin: BinDataCardValue.Selected, 'Quantity Received': Value(QuantityReceivedValue.Text), Notes: NotesDataCardValue.Text } ))
    ,
        //create the receipt for the existing item
        Set(varReceipt, Patch('Item Receipts', Defaults('Item Receipts'), {Item: ItemDataCardValue.Selected, Location: LocationDataCardValue.Selected, Cabinet: CabinetDataCardValue.Selected, Bin: BinDataCardValue.Selected, 'Quantity Received': Value(QuantityReceivedValue.Text), Notes: NotesDataCardValue.Text }));
     
        //update the total quantity on hand for the item received (if existing)
        Patch(Items, ItemDataCardValue.Selected, { 'On Hand': varQuantityOnHand + Value(QuantityReceivedValue.Text) })
    );
     
    //update the receipt to completed
    Patch('Item Receipts', varReceipt, { Status: 'Status (Item Receipts)'.Inactive, 'Status Reason': 'Status Reason (Item Receipts)'.Received });
     
    ResetForm(frmAddItem);
    Navigate(InventoryList,ScreenTransition.CoverRight);
     
    It all works now!
     
    Sometimes you just need to walk away and then go back to it.
     
    Thanks.
    Joe

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard