web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collections in Gallery...
Power Apps
Answered

Collections in Gallery and patching to data source

(0) ShareShare
ReportReport
Posted on by 25

I have a problem I hope this community can help me resolve, it is around creating a collection, to then patch that collection to a new record(s) in another SharePoint list.

To explain my use case.  I built an App for our Standards and Compliance team to record audits and associated audit actions, part of the process is to select the relevant standards/clauses (ISO e.g. ISO27001 etc.) that was performed against a particular audit. I have created a way to do this, by opening up a new form and selecting the relevant standard/clause, which is fine if only one is selected, but in most cases there could be more than 5 clauses selected, the S&C auditors have asked if it is possible to select more than one at a time to reduce the time taken to select the relevant clauses for each standard.

What I am struggling to do is to patch the selected items to create new record(s) to the relevant SharePoint list (SelectedStandard). I am aware I need to create a collection from the bottom gallery (see attached PDF with all details and explanations) to be able to patch. 

In the attached PDF, Page 1 shows my proposed screen mock up (once I've resolved the collection/patch issue, I will hide the bottom gallery from the users view), Page 2 shows the top gallery with a couple of items selected, Page 3 shows the bottom gallery of the two selected items in the top gallery along with the label names and their 'text' values, Page 4 shows the current screen which shows how it looks in the audit details screen (Audit scope tab), Page 5 shows the two SharePoint lists and how their relationship is linked, and Page 6 shows the lookup list 'Standards'.

I have looked at quite a few YouTube tutorials, but not been able to find one that matches my use case.

Thank you in advance for your consideration and help.

Derek

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @DerekGray 

    It is my understanding that you will be adding new items to the SelectedStandards list from the collection obtained by checking items in your gallery and as this is an audit trail, you are not modifying existing items.  If this is the case, as long as the field names in the collection match the field names in the SelectedStandards list, you can do a simple Collect(SelectedStandards, yourCollectionName).  You may need to shape your collection first to match match column names or remove columns from the collection.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @DerekGray 

    It is my understanding that you will be adding new items to the SelectedStandards list from the collection obtained by checking items in your gallery and as this is an audit trail, you are not modifying existing items.  If this is the case, as long as the field names in the collection match the field names in the SelectedStandards list, you can do a simple Collect(SelectedStandards, yourCollectionName).  You may need to shape your collection first to match column names or remove columns from the collection.

  • DerekGray Profile Picture
    25 on at

    Thank you for your reply.  Yes that is correct, I want to add the selected list of items to be created as new records in the SelectedStandards list, however 5 of the items in the bottom gallery come from a variable (varAudit) I set when opening up the audit record, so would I need to add anything else when creating the collection?

     

    In respect of matching fields in the collection, yes they all do match in the column names.

    Regards

    Derek

     

  • DerekGray Profile Picture
    25 on at

    Just to provide an update, after nearly a week of trial and error, I finally managed to construct the correct Collection/Patch code to work, I had to make a few tweaks for the item property type e.g. ParentID is a number type and the Audit date is a Date/Time type.  Copy of the code for anyone who has a similar issue.

     

    Collect(
    colSelectedItemsStd,
    galSelectedItems.AllItems
    );
    Patch(
    Selected Standard,
    ForAll(
    galSelectedItems.AllItems,
    {
    SelStandard: lblStandard.Text,
    SelClauses: lblClauses.Text,
    ParentID: Value(lblAuditID.Text),
    Audit Number: lblAuditNumber.Text,
    Audit Title: lblAuditTitle.Text,
    DateOfAudit: lblAuditStartDate.Text,
    Audit Date: DateTimeValue(lblAuditStartDate_1.Text),
    Calendar Name: lblCalendar.Text
    }
    )
    );
    Clear(colSelectedItemsStd)

     

    Thank you  for your help 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard