cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AshleyFoozi
Frequent Visitor

Repeating Table and Dropdown

Hi All. I have seen a similar question here which has not been adequately answered. 

I have a repeating table in a gallery (using Shane Young's brilliant Youtube videos). In the row I have several fields; some text boxes and others drop downs. After filling the first row and creating the next row, I noticed that the selected drop down values go back to the first value of the Items. When looking at the collection the values are correct. Some users might think that their entry hasn't been saved. I have other repeating tables without drop downs and they work perfectly. Anybody have any suggestions?

First row entry.......

Capture1.PNG

Second Row entry.......

Capture2.PNG

 

36 REPLIES 36

I did try leaving the Default of the dropdown blank but in all my frustration added data.

I guess I am not understanding what the DefaultSelectedItems is and how do I update this to your recommended Filter?  Because all I see is the Items and Default options.  Thank you for your patience.

My deepest apologies as I hardly ever use Drop Down controls as I prefer comboboxes instead since they have a lot more flexibility. All I was directing is true for comboboxes but when I tried myself with a drop-down box I see there's no DefaultSelectedItems property and the configuration is a bit different. With using a drop-down I wasn't getting any choices just pointing to the SPList.ColumnName so I had to use distinct - maybe you won't need to. For the patch you need to specify the selected result and then your Default property is simply ThisItem.ColumnName. All that to say try this:

 

ddPlanName.Items: Distinct(ActiveProjects.PlanName, PlanName)

ddPlanName.Default: ThisItem.PlanName

 

When you patch to the collection you need to use ...{PlanName: ddPlanName.SelectedText.Result

If you don't need the distinct for your lookup you should be fine with what you have already - ...{PlanName: ddPlanName.SelectedText.Value

 

As noted before you just need the Hours control in your form Default property set to Sum(ECPLCollection, Hours)

Thank you again for your assistance. Everything looks correct when I save.  However, the first choice is repeating when it patches to SharePoint.  The total hours is now correct in the form and remains correct when saved.  However, the PlanName and Hours in  the secondary SharePoint list copied 3 rows of the same data again.  I also followed Shane's example and my MasterID is not working.  I was hoping this would function once everything was correct.  But even sending incorrect data, the ID does not appear on either SharePoint list.

Perhaps I should consider a ComboBox with the PlanName and hours?  I have never done a combobox, but not afraid to try.  My hours is also a dropdown selection, not a text entry.  Management wants to make sure increments are controlled and only in .25 and not random entries.  Unfortunately, this entry form is extremely complex and I have five more screens to create for the additional data.  The form will collect the totals for all the screens onto the Details SharePoint page.  The Galleries will all submit to a different SharePoint list.  

Hi. I think you have really confused and frustrated yourself. Start again by using Shane Young's 3 part videos on this exact topic. In my experience a combo box is extremely difficult to use in repeating tables.

Delete and start again following the steps in here: https://youtu.be/xgznk4XlPCo

It will be worth your while.

 

An example:

My button to start the app and create 4 columns in the collection (Date, Used By, Area and Site)

NewForm(FormData);
ClearCollect(CollectionArea,{Date:"",UsedBy:"",Area:"",Site:"",ShowSaveButtonArea: true});

Save Button next to each line in the gallery repeating table  "On Select"

Patch(CollectionArea,ThisItem,{UsedBy:TxtTech.Text,Date:DatePicker1.SelectedDate,Site:DpdnSite.SelectedText.Value,Area:TxtArea.Text,ShowSaveButtonArea:false});
If(EditPressed1,false,Collect(CollectionArea,{UsedBy:"",Date:"",Site:"",Area:"",ShowSaveButtonArea:true}));UpdateContext({EditPressed1:false})

Edit Button next to each line in the gallery repeating table  "On Success"

Patch(CollectionArea,ThisItem,{ShowSaveButtonArea:true});UpdateContext({EditPressed1:true})

This code is in the On Success of my form. This submits the form data to one SharePoint list and patches the rows of data to another SharePoint list

CollectionArea,If(!IsBlank(Area),Patch('Pesticide Usage Log',Defaults('Pesticide Usage Log'),{
UsedBy:UsedBy,Date:DateValue(Date),Title:Site,Area:Area,
})));

 The default value for Site Dropdown is Site and for the Area text box it is Area

 

I am in pest control and using this forum and it's brilliant members I have created an app that uses a combination of PowerApps and Flow to produce a signed and emailed PDF customer service report and to enter service data in various SharePoint lists. In 2 months we have submitted over 11000 reports and saved paper worth a forest of trees. The submitted data is now invaluable to us when analyzed.  All this was done using this and other Microsoft forums. Thank you!

 

As @AshleyFoozi says it is probably a good idea to go back to Shane's videos, but it sounds like you need to look at both the patch to the collection (before saving the SP form) and the patch that saves the items to a separate SP list that would be in the form's OnSuccess property. Make sure the destination SP list has a MasterID column to write to and you should be referring to the main item's id in that OnSuccess patch statement using - MasterID: ECPLDetailsForm.LastSubmit.ID. I'm not sure why Ashley doesn't have a ForAll operator but to write the PlanName and Hours to the secondary list your patch statement should at least have:

 

ForAll(ECPLCollection, If(!IsBlank(PlanName), Patch(SecondarySharePointListName, Defaults(SecondarySharePointListName), {PlanName: PlanName, Hours: Hours, MasterID: Form1.LastSubmit.ID})))

 

I reviewed Shane's Video again and cannot find anything I did incorrect.  Except using dropdown fields and selected.text statements vs. text.

Below are all my commands and my Patch statements.  No error messages on any statements.  I do have the ID working on the Primary SharePoint List.  It does not work on the Secondary "CodeRightCollection" SharePoint List.  If I enter three repeating rows, only data for one row appears 3 times.  The correct total "Hours" in the Gallery is now appearing on the primary SharePoint List.  (Thank you for the help on formula).

The Gallery, data is appearing correctly in my dropdown fields (inside the Gallery).  However, It patches only one row three times to the "CodeRightCollection" list.  I have to be close to a resolution.  

 

1. New Form Statement.

NewForm(ECPLDetailsForm); ClearCollect(ECPLCollection, {PlanName: "", Hours: 0}); ResetForm(ECPLDetailsForm); Navigate(CodeRightScreen,Cover)

 

2. Form ForALL statement.  CodeRightCollection is my secondary SP List. 

 

ForALL(ECPLCollection, If(!IsBlank(PlanName), Patch(CodeRightCollection, Defaults(CodeRightCollection), {PlanName: ddPlanName.SelectedText.Value, Hours: Value(ddHours.SelectedText.Value), ECPLID: ECPLDetailsForm.LastSubmit.ID})))

 

3.  Save Icon inside the Gallery.  

Patch(ECPLCollection, ThisItem, {PlanName: ddPlanName.SelectedText.Value, Hours: Value(ddHours.SelectedText.Value)})): Collect(ECPLCollection, {PlanName: '', Hours" 0.00})

 

4.  Save Form Icon

SubmitForm(ECPLDetailsForm); ResetForm(ECPLDetailsForm); Notify("ECPL Submitted", Success); Navigate(ECPLScreen)

Your patch is writing just the last selected row in the gallery and not the collection item row. Yours basically says "For each collection row write the current selected gallery item." See my last reply on the patch as you want to write what's in the collection not what's currently selected in the gallery. The columns you're writing in your patch statement should be from the collection:

 

PlanName: PlanName, Hours: Hours, ECPLID: ECPLDetailsForm.LastSubmit.ID

I changed the ForAll Statement to:  ForAll(ECPLCollection, If(!IsBlank(PlanName), Patch(CodeRightCollection, Defaults(CodeRightCollection), {PlanName: PlanName, Hours: Hours, ECPLID: ECPLDetailsForm.LastSubmit.ID})))  

No error messages.  However, my Gallery now disappears in Preview mode or if I Select ALT and ddPlanName, it disappears.  

DisplayMode for the Gallery = Edit; OnSelect for Gallery = false.  Not sure what else I need to verify that could be causing this when I change the ForAll statement.

I don't know how that would impact your gallery. This statement is in the OnSuccess property of the main form, right? Your gallery datasource is the virtual collection? 

After sending last message, I refreshed the form and the Gallery is now visible.  But the Gallery data no longer retains selected drop down choice when Patch selected for next row. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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