cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ashwinijain932
Regular Visitor

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 @ashwinijain932 ,

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 @ashwinijain932 ,

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

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (843)