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 / Submitting collection ...
Power Apps
Answered

Submitting collection to various forms using switch?

(0) ShareShare
ReportReport
Posted on by

Hi All,

 

I have x3 inputs of user data (from Office365) and two text inputs that pre populate with SP choice column data based on Radio button choices.

 

All 5 inputs are then placed into a collection.

 

The collection is working fine:

 

ClearCollect(
 AckCollection,
 {
 col_ReviewYear: reviewyearTextInput.Text,
 col_AckType: AckTextInput.Text,
 col_Function: FunctionTextInput.Text,
 col_Department: DepartmentTextInput.Text,
 col_Name: nameComboBox.Selected.displayName,
 col_Role: roleComboBox.Selected.jobTitle,
 col_Email: emailComboBox.Selected.userPrincipalName,
 col_Date: DatePicker.SelectedDate
 }
)

What I am now running into trouble with is, I want to patch the collection to various lists based on the radio choice.

 

Eg.:

If Radio option 1 is chosen, patch to SP list 1

If Radio option 2 is chosen, patch to SP list 2

If Radio option 3 is chosen, patch to SP list 3

 

Can anyone assist please?

 

Thank you muchly.

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @DGWolfe ,

     

    We can use If() function something like:

    If(Radio1.Selected.Value="first",Patch(First List,...),Radio1.Selected.Value="second",Patch(Second List,...))

     

    Best Regards,

    Wearsky

  • WarrenBelz Profile Picture
    154,951 Most Valuable Professional on at

    Hi @DGWolfe ,

    Just a bit of hard coding

    Switch(
     RadioName.Selected.Value,
     "Option1",
     Patch(
     SPList1,
     ForAll(
     AckCollection,
     {
     ReviewYear: colReviewYear,
     . . . . . . .
     },
     )
     ),
     "Option2",
     Patch(
     SPList2,
     ForAll(
     AckColleciton,
     { . . . . 

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DGWolfe Profile Picture
    on at

    Thanks, I tried that but it's not working.

  • WarrenBelz Profile Picture
    154,951 Most Valuable Professional on at

    @DGWolfe ,

    Can you please share the code that is not working in Text - also what is not working (do you get errors or just no results?) I am assuming here you want new records in SharePoint.

  • DGWolfe Profile Picture
    on at

    Thanks @WarrenBelz , yes, trying for NEW data submission, not edit.

     

    It's getting a lot red around the collection parameters.

     

    I have tried a few different versions, but nothing.

     

    this is what I currently have (just using one radio option to see if that would work before I plugged them all in)

     

    If(
    
    DepartmentRadio.Selected.Value,="Risk",
    Patch(
     'Acknowledgement Risk - PA',AckCollection,
     {
     'Review Year': col_ReviewYear,
     'Acknowledgement Type': col_AckType,
     Function: col_Function,
     Department: col_Department,
     Name: col_Name,
     Role: col_Role,
     'u Number': col_Email,
     'Date Acknowledged': col_Date
     }
     )
    )
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @DGWolfe ,

     

    Please try this:

    If(
    
    DepartmentRadio.Selected.Value="Risk",
    ForAll(AckCollection,
    Patch(
     'Acknowledgement Risk - PA',Defaults('Acknowledgement Risk - PA'),
     {
     'Review Year': col_ReviewYear,
     'Acknowledgement Type': col_AckType,
     Function: col_Function,
     Department: col_Department,
     Name: col_Name,
     Role: col_Role,
     'u Number': col_Email,
     'Date Acknowledged': col_Date
     }
     ))
    )

     

    Best Regards,

    Wearsky

  • Verified answer
    WarrenBelz Profile Picture
    154,951 Most Valuable Professional on at

    Hi @DGWolfe ,

    Please trythis for the first item - note if you use this pattern (Patch the ForAll Table rather than ForAll loop the Patch) you will see significant performance improvements. ForAll creates a Table that can be patched in one action.

    If(
     DepartmentRadio.Selected.Value = "Risk",
     Patch(
     'Acknowledgement Risk - PA',
     ForAll(
     AckCollection,
     {
     'Review Year': col_ReviewYear,
     'Acknowledgement Type': col_AckType,
     Function: col_Function,
     Department: col_Department,
     Name: col_Name,
     Role: col_Role,
     'u Number': col_Email,
     'Date Acknowledged': col_Date
     }
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DGWolfe Profile Picture
    on at

    @WarrenBelz 

     

    Still not working. I've tried that exact formula a few times (and even written it out). I keep getting "Invalid argument type (Table). Expecting a value instead

  • WarrenBelz Profile Picture
    154,951 Most Valuable Professional on at

    @DGWolfe ,

    Which field (I simply copied your code) ? Can you please list the field types of all the items patched.

  • DGWolfe Profile Picture
    on at

    @WarrenBelz I see where you are going with that. One of the columns was a choice. I have switched this to single line of text and now it runs perfect. Thank you!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard