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.
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.
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.
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

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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