cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mezcalbean
Helper II
Helper II

Patching a toggle button to SharePoint

HI, Im confusing myself - how can I patch a toggle button to SharePoint, any help would be great, thanks

 

 

Patch(
    SPNAME,
    Defaults(SPNAME),
    {
        NameTitle: If(
           Toggle1.Value
            "Fred",
           "John"
        )
    }

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @mezcalbean ,

You are missing a comma after Toggle1.Value and a closing bracket at the end, but other than that, it should create a new record with either Fred or John in the field NameTitle in your List SPName.

 

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

View solution in original post

EddieE
Solution Sage
Solution Sage

@mezcalbean 

You are missing a closing bracket at the end of your code.

 

The rest of you code looks fine, what's the error? I've made some assumptions to the error and provided a tip below that may help.

 

When creating new records in SP you must include any REQUIRED fields in your Patch statement. Usually, Title is REQUIRED so your code should be

 

Patch(
    SPNAME,
    Defaults(SPNAME),
    {
        Title: "", 

        NameTitle: If(
           Toggle1.Value
            "Fred",
           "John"
        )
    }
)

 

If you have any other REQUIRED fields, these must also be included. If you are just Updating a record, REQUIRED fields usually aren't needed.

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @mezcalbean ,

You are missing a comma after Toggle1.Value and a closing bracket at the end, but other than that, it should create a new record with either Fred or John in the field NameTitle in your List SPName.

 

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

EddieE
Solution Sage
Solution Sage

@mezcalbean 

You are missing a closing bracket at the end of your code.

 

The rest of you code looks fine, what's the error? I've made some assumptions to the error and provided a tip below that may help.

 

When creating new records in SP you must include any REQUIRED fields in your Patch statement. Usually, Title is REQUIRED so your code should be

 

Patch(
    SPNAME,
    Defaults(SPNAME),
    {
        Title: "", 

        NameTitle: If(
           Toggle1.Value
            "Fred",
           "John"
        )
    }
)

 

If you have any other REQUIRED fields, these must also be included. If you are just Updating a record, REQUIRED fields usually aren't needed.

mezcalbean
Helper II
Helper II

Thank you @EddieE and @WarrenBelz for your reply - who do I give the accept solution too?

@mezcalbean 

You can tick both as solutions, the Forum allows this 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,842)