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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (78,558)