cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mezcalbean
Advocate II
Advocate 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
Super User
Super User

@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
Super User
Super User

@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
Advocate II
Advocate 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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,465)