cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rknight
Helper II
Helper II

App updates Excel sheet when 1 item submitted, but not when multiple items submitted

I have an app that allows users to update an inventory list of cabling. When the user submits the changes, they are supposed to appear on a table in an Excel spreadsheet. When the user only changes 1 item, it adds it perfectly to the sheet. However, if they adjust multiple items, it doesn't put anything into the table. Not sure why that is. Screenshots are below.

 

**2 items selected

rknight_0-1615470380119.png

**Take button code

 

Set(_Checked, CountRows(Filter(Gallery2.AllItems,Checkbox2.Value=true))) ; 
If(_Checked>0,Set(_popup,true),Notify("Please select one or more options.")) ;
Set(_takePressed,true)

 

**Pop up window with checked items

rknight_1-1615470483385.png

**Pop up window gallery (Gallery7) code; pulling from main gallery (Gallery2)

 

ForAll(
    Filter(Gallery2.AllItems,Checkbox2.Value) As _item,
    {ID: _item.ID,
    Length: _item.Length,
    Color: _item.Color,
    Quantity: _item.Quantity,
    'Item Name':_item.Name
    }
)

 

 **Update button code

 

Patch('Inventory Tracking - TESTING',
ForAll(
        Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) As _item,
        {ID: _item.ID,
        Quantity: _item.Quantity + (Value(_item.TextInput2_3.Text) * If(_addPressed,1,-1))
        }
        )
)
 ;
Collect(InventoryUsed,
ForAll(Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) As _item2,
{'Product Name':_item2.'Item Name',
Color:_item2.Color.Value,
Length:_item2.Length.Value,
Quantity:_item2.TextInput2_3.Text}
));    



Set(_addPressed,false);
Set(_takePressed,false);
Set(_popup,false); 
Set(isChecked,false); 
Set(isChecked,true)

 

 

This does not work as intended as it doesn't put those values into the Excel sheet. Any thoughts would be extremely helpful!

 

@RandyHayes 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@rknight 

Hmmm...that is strange!  I am wondering if this is a limitation with the Excel connector.  I don't work enough with the Excel connector to have discovered all of its little quirks. 

 

Let's try another approach:

With({_items: Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) },
    Patch('Inventory Tracking - TESTING',
        ForAll(_items As _item,
            {ID: _item.ID,
             Quantity: _item.Quantity + (Value(_item.TextInput2_3.Text) * If(_addPressed,1,-1))
            }
        )
    );

    Patch(InventoryUsed,
        ForAll(_items As _item2,
           Patch(Defaults(InventoryUsed),
               {'Product Name':_item2.'Item Name',
                Color:_item2.Color.Value,
                Length:_item2.Length.Value,
                Quantity:_item2.TextInput2_3.Text}
           )
        )
    )
);

Set(_addPressed,false);
Set(_takePressed,false);
Set(_popup,false); 
Set(isChecked,false); 
Set(isChecked,true)

 

Let's see if that makes any difference.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@rknight 

Are you getting all the selected items in your SharePoint list?  Or does it happen to both the list and the Excel?

 

Let's make a slight change (in case if you referential formulas are getting adjusted with the first Patch):

With({_items: Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) },
    Patch('Inventory Tracking - TESTING',
        ForAll(_items As _item,
            {ID: _item.ID,
             Quantity: _item.Quantity + (Value(_item.TextInput2_3.Text) * If(_addPressed,1,-1))
            }
        )
    );

    Collect(InventoryUsed,
        ForAll(_items As _item2,
           {'Product Name':_item2.'Item Name',
            Color:_item2.Color.Value,
            Length:_item2.Length.Value,
            Quantity:_item2.TextInput2_3.Text}
        )
    )
);

Set(_addPressed,false);
Set(_takePressed,false);
Set(_popup,false); 
Set(isChecked,false); 
Set(isChecked,true)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
rknight
Helper II
Helper II

I didn't have any errors with this new code, but it still isn't updating the spreadsheet when more than 1 item is checked and updated. It updates when 1 item is in Gallery7, but not when there are multiple.

RandyHayes
Super User
Super User

@rknight 

Hmmm...that is strange!  I am wondering if this is a limitation with the Excel connector.  I don't work enough with the Excel connector to have discovered all of its little quirks. 

 

Let's try another approach:

With({_items: Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) },
    Patch('Inventory Tracking - TESTING',
        ForAll(_items As _item,
            {ID: _item.ID,
             Quantity: _item.Quantity + (Value(_item.TextInput2_3.Text) * If(_addPressed,1,-1))
            }
        )
    );

    Patch(InventoryUsed,
        ForAll(_items As _item2,
           Patch(Defaults(InventoryUsed),
               {'Product Name':_item2.'Item Name',
                Color:_item2.Color.Value,
                Length:_item2.Length.Value,
                Quantity:_item2.TextInput2_3.Text}
           )
        )
    )
);

Set(_addPressed,false);
Set(_takePressed,false);
Set(_popup,false); 
Set(isChecked,false); 
Set(isChecked,true)

 

Let's see if that makes any difference.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,392)