cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kevin_Maxwell
Advocate I
Advocate I

Insert multiple results/items from Collection to SharePoint list

I'm trying to insert new collection values to SharePoint list. However, I get "An error occurred on the server.". Am I missing something?

 

 

ForAll(Beneficiary_Collection,
Patch(Beneficiary,
    {
    Beneficiary_Code: Beneficiary_Code,
    Order_Number: Value(Order_Number),
    First_Name: First_Name,
    Last_Name: Last_Name,
    Gender:
    {
    '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: LookUp( Gender_Lookup, Gender = English_Def, ID ),
    Value: LookUp( Gender_Lookup, Gender = English, English_Def )
    },
    Date_Of_Birth: Date_of_Birth
    })
)

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Kevin_Maxwell,

 

Could you please share a bit more about the Beneficiary that you mentioned? Is it a SP list on your side?

Further, could you please share a bit more about your SP list?

 

I found that you have posted a similar issue within this forum and I have made a response to it. Please check the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/How-to-loop-collection-lookup-values/m-p/1270...

 

Based on the formula that you provided, I think there is something wrong with the Patch function within your formula. I assume that the Beneficiary that you mentioned is a SP list and you want to add a new item into your SP list using Patch function, I think you have ignored the Defaults function.

 

Please take a try to modify your formula as below:

ForAll(Beneficiary_Collection,
Patch(Beneficiary,Defaults(Beneficiary),
    {
    Beneficiary_Code: Beneficiary_Code,
    Order_Number: Value(Order_Number),
    First_Name: First_Name,
    Last_Name: Last_Name,
    Gender:
    {
    '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: LookUp( Gender_Lookup, Gender = English_Def, ID ),
    Value: LookUp( Gender_Lookup, Gender = English, English_Def )
    },
    Date_Of_Birth: Date_of_Birth
    })
)

More details about the Patch function in PowerApps, please check the following article:

Patch function

 

 

Best regards,

Kris

 

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

 

Could you please share a bit more about the Beneficiary that you mentioned? Is it a SP list on your side?

Further, could you please share a bit more about your SP list?

 

I found that you have posted a similar issue within this forum and I have made a response to it. Please check the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/How-to-loop-collection-lookup-values/m-p/1270...

 

Based on the formula that you provided, I think there is something wrong with the Patch function within your formula. I assume that the Beneficiary that you mentioned is a SP list and you want to add a new item into your SP list using Patch function, I think you have ignored the Defaults function.

 

Please take a try to modify your formula as below:

ForAll(Beneficiary_Collection,
Patch(Beneficiary,Defaults(Beneficiary),
    {
    Beneficiary_Code: Beneficiary_Code,
    Order_Number: Value(Order_Number),
    First_Name: First_Name,
    Last_Name: Last_Name,
    Gender:
    {
    '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: LookUp( Gender_Lookup, Gender = English_Def, ID ),
    Value: LookUp( Gender_Lookup, Gender = English, English_Def )
    },
    Date_Of_Birth: Date_of_Birth
    })
)

More details about the Patch function in PowerApps, please check the following article:

Patch function

 

 

Best regards,

Kris

 

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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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