cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andyh1
Regular Visitor

Update Textbox within Gallery

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4
RusselThomas
Community Champion
Community Champion

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

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

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

Thanks so much - worked a treat!

Helpful resources

Announcements

Super User of the Month | Drew Poggemann

As part of a new monthly feature in the Community, we are excited to share that Drew Poggemann is our featured Super User for the month of February 2024. If you've been in the Community for a while, we're sure Drew's name is familiar to you, as he is one of our most active contributors--he's been a Super User for five consecutive seasons!   Since authoring his first reply 5 years ago to his 514th solution authored, Drew has helped countless Community members with his insights and expertise. In addition to being a Super User, Drew is also a User Group leader and a Microsoft MVP. His contributions to our Super User sessions and to the new SUIT program are always welcome--as well as his sense of humor and fun-loving way of sharing what he knows with others.   When Drew is not solving problems and authoring solutions, he's busy overseeing the Solution Architecture team at HBS, specializing in application architecture and business solution strategy--something he's been doing for over 30 years. We are grateful for Drew and the amazing way he has used his talent and skills to help so many others in the Community. If you are part of the SUIT program, you got to hear some great tips from Drew at the first SUIT session--and we know he still has much more to share!You can find him in the Community and on LinkedIn. Thank you for all you do, Drew!

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Our team will be reviewing posts using the new "Copilot Studio" label to ensure we highlight and amplify the most relevant and recent content, so you're assured of high-quality content every time you visit. If you share a post that gets featured in the curated gallery, you'll get a PM in the Community to let you know!The curated gallery is ready for you to experience now, so visit the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!      

Celebrating a New Season of Super Users with Charles Lamanna, CVP Microsoft Business Applications

February 8 was the kickoff to the 2024 Season One Super User program for Power Platform Communities, and we are thrilled to welcome back so many returning Super Users--as well as so many brand new Super Users who started their journey last fall. Our Community Super Users are the true heroes, answering questions, providing solutions, filtering spam, and so much more. The impact they make on the Communities each day is significant, and we wanted to do something special to welcome them at our first kickoff meeting of the year.   Charles Lamanna, Microsoft CVP of Business Applications, has stressed frequently how valuable our Community is to the growth and potential of Power Platform, and we are honored to share this message from him to our 2024 Season One Super Users--as well as anyone who might be interested in joining this elite group of Community members.     If you want to know more about Super Users, check out these posts for more information today:    Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

February 2024 User Group Update: Welcoming New Groups and Highlighting Upcoming Events

It's a new month and a brand-new year, which means another opportunity to celebrate our amazing User Groups!Each month, we highlight the new User Groups that have joined the community. It's been a busy season for new groups, because we are thrilled to welcome 15 New User Groups! Take a look at the list below, shared by the different community categories. If your group is listed here, give this post a kudo so we can celebrate with you!   We love our User Groups and the difference they make in the lives of our Community! Thank you to all the new User Groups, new User Group leaders--we look forward to hearing about your successes and the impact you will leave!   In addition to our monthly New User Group spotlight, it's a great time to share some of the latest events happening in our User Group community! Take a look at the list below to find one that fits your schedule and need! There's a great combination of in-person and virtual events to choose from. It's a great time of year to connect and engage with User Groups both locally and online. Please Welcome Our NEW User Groups   Power Platform: Heathcare Power Platform User Group Power Platform Connect Hub Power Platform Usergroup Denmark Mexico Norte- Power Platform User Group Pune Power User Group Sudbury Power Platform User GroupMicrosoft User Group GhanaMPPBLR - Microsoft Power Platform Bengaluru User Group Power Apps:   Myrtle Beach Power Platform User GroupAnanseTechWB PowerApps Copilot Studio: Pathfinders Power Platform Community Dynamics365: Cairo, Egypt MSD 365 Business Central/NAV/F&O User GruopMS Dynamics 365 Business Central LatamCincinnati OH D365 F&O User Group February User Group Events February 2024 Cleveland Power Platform User GroupPortallunsj - Februar 2024Indiana D365/AX February User Group MeetingQ1 2024 KC Power Platform and Dynamics 365 CRM Users Group 

Super Users 2024 Season One is Here!

   We are excited to announce the first season of our 2024 Super Users is here! Our kickoff to the new year welcomes many returning Super Users and several new faces, and it's always exciting to see the impact these incredible individuals will have on the Community in 2024! We are so grateful for the daily difference they make in the Community already and know they will keep staying engaged and excited for all that will happen this year.   How to Spot a Super User in the Community:Have you ever written a post or asked for help in the Community and had it answered by a user with the Super User icon next to their name? It means you have found the actual, real-life superheroes of the Power Platform Community! Super Users are our heroes because of the way they consistently make a difference in the Community. Our amazing Super Users help keep the Community a safe place by flagging spam and letting the Community Managers know about issues. They also make the Community a great place to find answers, because they are often the first to offer solutions and get clarity on questions. Finally, Super Users share valuable insights on ways to keep the Community growing, engaging, and looking ahead!We are honored to reveal the new badges for this season of Super Users! Congratulations to all the new and returning Super Users!     To better answer the question "What is a Super User?" please check out this article: Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Did You Attend the Microsoft Power Platform Conference in 2022 or 2023? Claim Your Badge Today!

If you were one of the thousands of people who joined us at the first #MPPC Microsoft Power Platform Conference in 2022 in Orlando--or attended the second-annual conference in Las Vegas in 2023--we are excited to honor you with a special community badge! Show your support for #MPPC Microsoft Power Platform Conference this year by claiming your badge!         Just follow this link to claim your badge for attending #MPPC in 2022 and/or 2023: MPPCBadgeRequest    Want to earn your badge for 2024? Just keep watching our News & Announcements for the latest updates on #MPPC24.

Top Solution Authors
Top Kudoed Authors
Users online (8,864)