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 / Combine Switch and Pat...
Power Apps
Unanswered

Combine Switch and Patch to generate a record to a SharePoint List

(1) ShareShare
ReportReport
Posted on by 121

I am using the Switch function to utilise different SharePoint Lists when viewing a gallery,

 

I am trying to write to the selected SharePoint List using a Patch function, 

 

I am using the following but generates an error.

Patch(Switch(
 Dropdown6.Selected.Value,
 "Cov", Cov_SP,
 "Wor", Wor_SP),
 ThisItem,
 {
 'Shift Date': DataCardValue5_1.SelectedDate,
 'Shift Time': DataCardValue7_1.Text,
 'Skill Set': DataCardValue14_1.Selected,
 Location2: Dropdown2.Selected
 }
)

 

Can anyone see where i'm going wrong please.

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,960 Moderator on at

    Hi @Markswan20 

     

    What error I don't see it? I'd love to guess it, but my wife stole my crystal ball and all knowing mirror 🙂

     

    1. What exactly are you trying to do with this switch statement as you also don't explain that so honestly I have no clue.

     

    Let's reformat your code to see what it's doing better. So looking at it, what exactly is Cov_SP value going to? I don't see a Column Identified.

     

    So what this code, looks like it does

    1. says Cov_SP is the record you want to change, but even if true, you provided no values

    2. says Wor_SP is the record you want to change, but even if true, you provided no values

    3. Your fault says, ThisItem (are you in some gallery I don't see????) and logistically would try to patch ThisItem, but I have no idea if ThisItem is a Record or Table or a Value.

     

    Can you please explain what you were attempting please.

    Patch(
     Switch(Dropdown6.Selected.Value,
     "Cov", 
     Cov_SP,
     "Wor", 
     Wor_SP),
     ThisItem,
     {
     'Shift Date': DataCardValue5_1.SelectedDate,
     'Shift Time': DataCardValue7_1.Text,
     'Skill Set': DataCardValue14_1.Selected,
     Location2: Dropdown2.Selected
     }
    )

      
    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Markswan20 Profile Picture
    121 on at

    Thanks for the response, looking back at the original post a crystal ball would have definitely helped.

     

    My scenario is the following, I have 2 SharePoint Lists called Cov_SP & Wor_SP these hold the complete data for 2 locations. I have a dropdown box which allows the user to select either location. 

     

    The location is connected to a Gallery and the results from the drop down populate the gallery. Both lists have identical columns.

     

    What i am trying to do is allow the user to fill in a form that populates new information into the selected SharePoint list. I have used the SubmitForm command which works but i have specific information that needs to be patched that's pulled from a variable. 

     

    I may be going about the code wrong that was my attempt at trying, badly.

     

    Does this make any sense.

     

     

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard