cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Few collection values are not getting stored into the SharePoint List

I am creating an application as shown below in the picture. I am trying to update 'Adjusted Hours' and Comments for multiple rows simultaneously so that the entire data is saved with 1 click. In this case, I am storing all the updated values in a collection and sending the collection values to SharePoint list (after clicking on tick mark). All the values are getting stored in the collection but only few values are getting stored in the SharePoint list. I have checked the code multiple times and tried various things but, still not luck. Can someone please explain me if I am missing anything.

 

ashwinijain932_0-1598239891415.png

 

I used to below code to save all the entries into the collection. 

 

If(

    ThisItem.Job in Collection1.Job1 And ThisItem.WeekEnding in Collection1.WeekEnding1,

    Patch(

        Collection1,

        First(

            Filter(

                Collection1,

                Job1 = ThisItem.Job,

                WeekEnding1 = ThisItem.WeekEnding

                )

            ),

            {AdjustedHours : Value(TextInput5.Text)}

            ),

    Collect(

        Collection1,

        {

            Job1 : ThisItem.Job,

            WeekEnding1 : ThisItem.WeekEnding,

            AdjustedHours : Value(TextInput5.Text)

        }

    )

)

 

And, I used the below code to send the data to SharePoint list.

 

ForAll(

    Collection1,

    Patch(Hours, First(Filter(Hours, Job = Job1, WeekEnding = WeekEnding1)), {'Adjusted Estimate Hours':  AdjustedHours, Comments: Comments1}));

 Navigate(Screen2); Clear(Collection1)

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Regarding the formula that you mentioned, I think there is something logic issue with it. I have made a test on my side, please try to modify your formula as below:

 

Firstly, you should add the "+" icon inside the Gallery rather than outside the Gallery. Then you could update current Gallery Item and add new entry via pressing the "+" icon. Set the OnSelect property of the "+" icon inside the Gallery to following:

Patch(
           Collection1,
           LookUp(Collection1,Job1 = ThisItem.Job && WeekEnding1 = ThisItem.WeekEnding),
           {
              AdjustedHours : Value(TextInput5.Text)
           }
);
Collect(
        Collection1,
        {
            Job1 : ThisItem.Job,
            WeekEnding1 : ThisItem.WeekEnding,
            AdjustedHours : Value(TextInput5.Text),
            Comments1: ""    // you should also include the Comments1 field here when you add a new entry
        }
)

Note: I assume that you have initialized the Collection1 already when you load your canvas app. Please do not forget adding the Comments1 field in your Collect formula as above.

 

You should modify your ForAll formula as below:

ForAll(
       Collection1 As LoopRecord,  // Modify formula here
       Patch(
               Hours,
               If(    // Modify formula here. Detect if the collection record is exited in your SP List or not
                  IsBlank(LookUp(Hours, Job = LoopRecord.Job1 && WeekEnding = LoopRecord.WeekEnding1)),
                  Defaults(Hours),
                  LookUp(Hours, Job = LoopRecord.Job1 && WeekEnding = LoopRecord.WeekEnding1)
               ), 
              {
                  'Adjusted Estimate Hours':  LoopRecord.AdjustedHours, 
                  Comments: LoopRecord.Comments1
              }
       )
);
Navigate(Screen2);
Clear(Collection1)

Please consider try above solution, then check if all collection records has been updated in your SP List.

 

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

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Regarding the formula that you mentioned, I think there is something logic issue with it. I have made a test on my side, please try to modify your formula as below:

 

Firstly, you should add the "+" icon inside the Gallery rather than outside the Gallery. Then you could update current Gallery Item and add new entry via pressing the "+" icon. Set the OnSelect property of the "+" icon inside the Gallery to following:

Patch(
           Collection1,
           LookUp(Collection1,Job1 = ThisItem.Job && WeekEnding1 = ThisItem.WeekEnding),
           {
              AdjustedHours : Value(TextInput5.Text)
           }
);
Collect(
        Collection1,
        {
            Job1 : ThisItem.Job,
            WeekEnding1 : ThisItem.WeekEnding,
            AdjustedHours : Value(TextInput5.Text),
            Comments1: ""    // you should also include the Comments1 field here when you add a new entry
        }
)

Note: I assume that you have initialized the Collection1 already when you load your canvas app. Please do not forget adding the Comments1 field in your Collect formula as above.

 

You should modify your ForAll formula as below:

ForAll(
       Collection1 As LoopRecord,  // Modify formula here
       Patch(
               Hours,
               If(    // Modify formula here. Detect if the collection record is exited in your SP List or not
                  IsBlank(LookUp(Hours, Job = LoopRecord.Job1 && WeekEnding = LoopRecord.WeekEnding1)),
                  Defaults(Hours),
                  LookUp(Hours, Job = LoopRecord.Job1 && WeekEnding = LoopRecord.WeekEnding1)
               ), 
              {
                  'Adjusted Estimate Hours':  LoopRecord.AdjustedHours, 
                  Comments: LoopRecord.Comments1
              }
       )
);
Navigate(Screen2);
Clear(Collection1)

Please consider try above solution, then check if all collection records has been updated in your SP List.

 

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.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

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