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 / Update Textbox within ...
Power Apps
Answered

Update Textbox within Gallery

(0) ShareShare
ReportReport
Posted on by 7

Hi Everyone

 

I'm developing an inventory management app for our warehouse

 

I have a Gallery which draws from Data Table (SHELVES) which has a field called "SpaceAvail".  Each Item in the Gallery therefore tells me how much space is available to physically store boxes.  I have a variable called "NewGoods" which is populated by another process, and reflects the number of new items coming into the warehouse.

 

I've added a checkbox and a textbox (NewItems) to appear in each gallery, and now i want the user to be able to check the checkbox and it will automatically populate the textbox with either the full number of NewGoods or the SpaceAvail depending on which is greater.  Below is my text 

 

If(ThisItem.SpaceAvail>NewGoods,NewItemsText=NewGoods,NewItems.Text=ThisItem.SpaceAvail;NewGoods=NewGoods-ThisItem.SpaceAvail)

 

Issue seems to be passing the value to the textbox where i;ve coloured in red above.

 

I tried linking the value of the textbox to a variable but i'm stuck on how to do this if the gallery populates multiple items (and therefore textboxes) which may need NewGoods to be spread across

 

Many thanks for any help!

Andy

Categories:
I have the same question (0)
  • RusselThomas Profile Picture
    4,014 on at

    Hi @Andyh1 ,

    You're on the right track Smiley Happy  Just not sure where you're applying this formula.

    Depending on your desired outcome, there may be different answers, so let's see if I understand correctly first;

    1: To assign Newgoods to available space, you tick a checkbox on a 'shelf' that presumably shows available space.

    2: You can't split your packing, so a shelf must either take the full complement of Newgoods, or none.  You cannot put some of the Newgoods on one shelf and the rest on another?

    Showing available space on check is a little confusing for me - let's use a scenario to clarify;

    I have 10 boxes and 20 shelves.

    Each shelf can hold 50 boxes, many shelves are already full.

    • My first shelf has 8 available spaces.  
    • My second shelf is full.
    • My third shelf has 9 available spaces.
    • My fourth shelf has 15 available space.
    • ...and so on

    My gallery shows all 20 shelves with no filtering or sorting.  By your formula requirement, if I tick the checkbox for the first shelf, the text label in that row then shows 10 (the greater between available space and newGoods). Likewise with the second and third shelves also show 10.  If I tick the fourth shelf tickbox, it shows 15.

    I'm struggling to understand the logic behind this - it looks like you want a running total for NewGoods as you assign space, but what you're written seems to contradict that.  Anyway, assuming it's correct as is, is there any reason you can't just set the NewItems label Text: property to;

    If(ThisItem.SpaceAvail>NewGoods, ThisItem.SpaceAvail, NewGoods)

    You would need to put the behaviour formula to update the NewGoods value somewhere else - such as the OnChecked: property of the checkbox - but changing the NewGoods will obviously change the result of the text label - unless that's what you want?

    There are also ways to allow split-packing across shelves or even to auto-assign based on available space, but I'd prefer to make sure I'm understanding this properly before running off on a tangent Smiley Happy

    Kind regards,

    RT

  • Andyh1 Profile Picture
    7 on at
    Many thanks for the reply. I’m actually looking to split the good between shelves If I need to. My logic was to have a running total which reduced as shelves were selected and items distributed.

    Any other thoughts you have will be really appreciated
  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    Hi @Andyh1 ,

    Ok, so there's a few ways to do it - you may need to pick one that fits with the experience you're trying to create - also you need to decide on some preferences, such as;

    • Do you want to rather pack all newgoods onto one shelf, or would you prefer to first fill up remaining space on other shelves?
    • Do you need to keep a running total IN the gallery, or can it live outside the Gallery?

    Your preferences may change the answer, but let's make some assumptions and start with an example for you to start tweaking.

    Example assumptions:

    • Your Gallery is called "ShelfGallery"
    • The checkbox inside the Gallery is called "packedCheckBox"
    • NewGoods is a context variable

    This is just a quick and dirty way just to illustrate the logic. 
    Add a label to your page (not the gallery, otherwise you'll get a circular reference error) - call it lblRunningTotal and set its Text: property to;

     

    NewGoods - Sum(Filter(ShelfGallery.AllItems, packedCheckBox.Value), SpaceAvail)

    This will now Sum the available space of the checked items in the Gallery and subtract it from NewGoods.  NOTE: it does not change the value of NewGoods - it's just uses it to calculate a remaining value based on what's been checked.

    But we may also want to stop people from continuing to 'pack' when there are no more goods left to pack, so we can disable the CheckBoxes as soon as the number of NewGoods reaches 0 or less;

    Set the DisplayMode: property of packedCheckBox to;

     

    If(Value(lblRunningTotal.Text) <=0, 
     If(packedCheckBox.Value, 
     DisplayMode.Edit, DisplayMode.Disabled), 
    DisplayMode.Edit)

    So, if the packing calculation of NewGoods is less than or equal to 0, then we've packed all the items.  In that case Disable all checkboxes that haven't already been checked.  If you want to reorder or pack differently, you must first uncheck (unpack) from one of the shelves.

    So much for the quick and dirty - but you probably still want to update NewGoods to zero, or whatevers left over when you're done.  May also want to update the remaining space of each shelf once it's packed.

    For a more efficient performance and flexible function solution, you may want to keep an indexed collection of shelves that are being 'packed' and the space that's being used on them.  You can do this using the packedCheckBox OnCheck: and OnUncheck: properties to populate and remove entries in a collection, but you'll need to keep track of how much space on the current shelf was used in order to update it's remaining space value as well.

    You can also do things like sort and filter your ShelfGallery to show items with the most space first, or filter the gallery where the remaining space is precisely the same as the amount of NewGoods.

    A lot will depend on your preferences - but this should give you enough to get started Smiley Happy

     

    Hope it helps,


    RT

  • Andyh1 Profile Picture
    7 on at

    Thanks so much - worked a treat!

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 936

#2
Valantis Profile Picture

Valantis 604

#3
11manish Profile Picture

11manish 518

Last 30 days Overall leaderboard