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

Saving Data from Collection only Replicate the last value

Hi all,

 

I have a problem in saving all values from a collection. I created a set of input fields in a collection and i need to save all the data to a database.

Set of input fields in collectionSet of input fields in collection

I was able to patch the data to a database but when i checked the table, only the last value was saved and was replicated thrice.

Capture 02.PNG

 

Here's my formula.

 

Capture 03.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @escimorales ,

Based on the formula you provided, I could not find any syntax error with it. 

 

I have made a test on my side, and don't have the issue that you mentioned. Please consider modify your formula as below:

ForAll(
          TEST_agendaGallery_1.AllItems,
          Patch(
                    '[dbo].[Agenda]',
                     Defaults('[dbo].[Agenda]'),
                    {
                        MeetingId: Last('[dbo].[Meeting]_1').MeetingId,
                        Description: agendaTxtInput_1.Text,
                        TimeAllocation: Time(Value(AgendaAllocHours_1.Selected.Value), Value(AgendaAllocMinutes_1.Selected.Value), 0),
                        Responsible: Concat(MeetingAgendaAssignee_1.SelectedItems, EmployeeName & "; ")
                    }
          )
)

Also please consider take a try with the following formula:

ClearCollect(GalleryCollection, TEST_agendaGallery_1.AllItems);
ForAll( GalleryCollection, Patch( '[dbo].[Agenda]', Defaults('[dbo].[Agenda]'), { MeetingId: Last('[dbo].[Meeting]_1').MeetingId, Description: agendaTxtInput_1.Text, TimeAllocation: Time(Value(AgendaAllocHours_1.Selected.Value), Value(AgendaAllocMinutes_1.Selected.Value), 0), Responsible: Concat(MeetingAgendaAssignee_1.SelectedItems, EmployeeName & "; ") } ) ) 

Please take a try with above solution, check if the issue is solved.

 

If the issue still exists, please consider re-create a new app based on your data source, then try above formula again, check if the issue is fixed.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
PavanKumar
Responsive Resident
Responsive Resident

Hi Escimorales,

 

I would suggest you to first collect values in collection and check if they are showing as you required.

 

I have tried following and its working as expected. (I have placed a multiselect combobox and label controls in gallery)

 

//Loop through all items in gallery and collect in SelectedGalleryValues collection. This is useful if you have only one selected item in combobox.

ForAll(Gallery1.AllItems,Collect(SelectedGalleryValues,{combovalue:ComboBox2.SelectedItems.Value1,namevalue:FullName.Text}));

 

//This is useful if you need multiselected values in combobox.

ForAll(Gallery1.AllItems,Collect(SelectedGalleryValues2,{combovalue:Concat(ComboBox2.SelectedItems,Value1 & ","),namevalue:FullName.Text}));

 

1.PNG2.PNG

 

That's how my gallery and collection looks like.

 

If this answers your question plesae mark it as verified.

Regards,

Pavan Kumar Garlapati

@PavanKumar thanks. I'll try this one

v-xida-msft
Community Support
Community Support

Hi @escimorales ,

Based on the formula you provided, I could not find any syntax error with it. 

 

I have made a test on my side, and don't have the issue that you mentioned. Please consider modify your formula as below:

ForAll(
          TEST_agendaGallery_1.AllItems,
          Patch(
                    '[dbo].[Agenda]',
                     Defaults('[dbo].[Agenda]'),
                    {
                        MeetingId: Last('[dbo].[Meeting]_1').MeetingId,
                        Description: agendaTxtInput_1.Text,
                        TimeAllocation: Time(Value(AgendaAllocHours_1.Selected.Value), Value(AgendaAllocMinutes_1.Selected.Value), 0),
                        Responsible: Concat(MeetingAgendaAssignee_1.SelectedItems, EmployeeName & "; ")
                    }
          )
)

Also please consider take a try with the following formula:

ClearCollect(GalleryCollection, TEST_agendaGallery_1.AllItems);
ForAll( GalleryCollection, Patch( '[dbo].[Agenda]', Defaults('[dbo].[Agenda]'), { MeetingId: Last('[dbo].[Meeting]_1').MeetingId, Description: agendaTxtInput_1.Text, TimeAllocation: Time(Value(AgendaAllocHours_1.Selected.Value), Value(AgendaAllocMinutes_1.Selected.Value), 0), Responsible: Concat(MeetingAgendaAssignee_1.SelectedItems, EmployeeName & "; ") } ) ) 

Please take a try with above solution, check if the issue is solved.

 

If the issue still exists, please consider re-create a new app based on your data source, then try above formula again, check if the issue is fixed.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

PavanKumar
Responsive Resident
Responsive Resident

Glad your issue has been resolved now. Regards, Pavan Kumar Garlapati

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (2,776)