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

Sending Power Apps Collection to SharePoint List

I'm getting a bit desperate. 😟

 

My app that creates a multi-row collection of supplies the user wants to order, along with the quantity for each. The supply order must be approved by a manager before it is purchased. There is a "Submit Order" button.

 

Ideally, the "Submit Order" button sends all rows of the collection in a single email to the manager who then approves/rejects the order. If approved, each line of the list would be added to a SharePoint list, which would be reviewed and then supplies would be purchased.

 

Does anyone know how to do this? I've tried the Collect and Patch functions and they appear to work when I demo the app, but then nothing appears in the SharePoint list. I would need details on how to build the grid if there isn't a simple way to insert it into an email and then back into lines of a SharePoint list.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Kat_YESPrep ,

1)Do you want to create records in list by using the data of collection?

Please show me your collection's structure and the list's structure.

You need to tell me every column's data type.

If the collection's structure and the list's structure are exactly the same, including the field names, then you could use Collect function directly.

Try this:

Collect(listname, collectionname)

If the collection's structure and the list's structure are not the same or different field names, you need to use Patch and ForAll to update. (In this situation, data type is very important)

Try this:

ForAll(collection,Patch(list,Defaults(list),{field1name in list:list1name in collection,field2name in list:list2name in collection,.....})

 

2)Do you want to send email with the collection data?
I suggest you try to send email with html text.

Try this:

send email button's OnSelect:

Office365.SendEmail("to email address","subject", HtmlText1.HtmlText, {IsHtml:true})

HtmlText1's contecnt:

"<h3>Data Table HTML Email</h3>" &
"<strong> Items: </strong>" &
"<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
         <th>field1</th> <th> field2 </th> <th> field3 </th><th> field4 </th>
     </tr>
     <tr>" &
         Concat(listname,
             "<td>" & field1 & " </td>
              <td>" & field2 & " </td>
              <td>" & field3 & " </td>
              <td>" & field4 & " </td>","</tr><tr>") &
"</table>"

 The table will show like this in the email:  (html text)

 

Here's a doc about sending html text in email for your reference:

https://powerapps.microsoft.com/en-us/blog/html-email-reporting-with-tabular-data/

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

2 REPLIES 2
mdevaney
Super User III
Super User III

@Kat_YESPrep 

From my reading of your post I believe you are asked 2 questions:

 

#1  How can I send my Collection to the SharePoint list?

#2  How can I display a collection in an e-mail

 

It will be much easier to solve them one-at-a-time.  Let's focus on question #1 first.

 

This is the code I would use in your situation to insert all of the collection rows into a SharePoint list.

 

Collect(your_sharepoint_list, your_collection_name)

 

 

If it didn't work the 3 most likely possibilities are:

 

  • You don't have permission to add new list items.  To check go to your SharePoint list, click on the Share button and look for your name as an Owner.  Add your name if you don't appear
  • You made changes to the SharePoint list structure but haven't updated in PowerApps.  Click on the datasource name on the left-side menu and click Refresh.
  • Your collection has different columns and/or data types than the SharePoint list.  Check to make sure your Collection and SharePoint list are consistent.

 

If none of the above work would you please share a screenshot of your SharePoint list and details and of your collection?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

v-yutliu-msft
Community Support
Community Support

Hi @Kat_YESPrep ,

1)Do you want to create records in list by using the data of collection?

Please show me your collection's structure and the list's structure.

You need to tell me every column's data type.

If the collection's structure and the list's structure are exactly the same, including the field names, then you could use Collect function directly.

Try this:

Collect(listname, collectionname)

If the collection's structure and the list's structure are not the same or different field names, you need to use Patch and ForAll to update. (In this situation, data type is very important)

Try this:

ForAll(collection,Patch(list,Defaults(list),{field1name in list:list1name in collection,field2name in list:list2name in collection,.....})

 

2)Do you want to send email with the collection data?
I suggest you try to send email with html text.

Try this:

send email button's OnSelect:

Office365.SendEmail("to email address","subject", HtmlText1.HtmlText, {IsHtml:true})

HtmlText1's contecnt:

"<h3>Data Table HTML Email</h3>" &
"<strong> Items: </strong>" &
"<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
         <th>field1</th> <th> field2 </th> <th> field3 </th><th> field4 </th>
     </tr>
     <tr>" &
         Concat(listname,
             "<td>" & field1 & " </td>
              <td>" & field2 & " </td>
              <td>" & field3 & " </td>
              <td>" & field4 & " </td>","</tr><tr>") &
"</table>"

 The table will show like this in the email:  (html text)

 

Here's a doc about sending html text in email for your reference:

https://powerapps.microsoft.com/en-us/blog/html-email-reporting-with-tabular-data/

 

 

Best regards,

Community Support Team _ Phoebe Liu
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 (1,569)