Skip to main content

Notifications

Power Apps - Building 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.

  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Combine Switch and Patch to generate a record to a SharePoint List

    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.

     

     

  • FLMike Profile Picture
    FLMike 31,580 on at
    Re: Combine Switch and Patch to generate a record to a SharePoint List

    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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard