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 III
Super User III

@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 III
Super User III

@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 III
Super User III

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,387)