cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Power_user2
Frequent Visitor

Issues with creating a patch function

I am creating an application which will update different spreadsheets (which all have identical templates). I'm using a switch statement for that part. Reading on the forums, I saw that the best way to update different spreadsheets was by using a patch function.

Power_user2_4-1655402197083.png

 

Anyways, an issue I was having is that the patch function keeps showing that there are errors, despite the fact that my syntax appears to be correct. It is hard to see from this screenshot, so I have created another patch function with a simple function, that shows the same exact error as this function.

Power_user2_3-1655402095291.png

 

Is there a mistake I am making with patch functions?

 

GenJuly is the table, YES is a column.

 

 

On the first screenshot GenYES, GenNO, and GenComm are datacards.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Your issue is probably stemming from the syntax of the multiple statements in your code. It should look more like:

SubmitForm(EditForm1);
Reset(GenCBox);
Reset(RadioA);
Switch( // with the rest of your code
_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

8 REPLIES 8
BCLS776
Super User
Super User

Is your Switch function within a behavior property (one that starts with "On")? Patch() is a behavior function, so it can only be invoked from a behavior property.

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
v-jefferni
Community Support
Community Support

Hi @Power_user2 ,

 

It seems that you appended the formula on a Label or Text Input box, please try and use it on a Button's OnSelect as mentioned by @BCLS776 .

 

Best regards,

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hello, sorry for the delayed response. The Switch function is within an onselect property. 

Power_user2_0-1655913289357.png

 

The formula is being put onto an icon if that is relevant.

Your issue is probably stemming from the syntax of the multiple statements in your code. It should look more like:

SubmitForm(EditForm1);
Reset(GenCBox);
Reset(RadioA);
Switch( // with the rest of your code
_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Drrickryp
Super User
Super User

@Power_user2 

Don't chain commands with SubmitForm().  Put them in the OnSuccess property of the form.  You don't want them to execute if the form is not successfully submitted. 

Power_user2
Frequent Visitor

I've tried this and I believe you are right! Thanks for the help.

On a side note, how do you determine when to use semicolons between functions and when to use a plus sign?

Drrickryp
Super User
Super User

@Power_user2 

I've never used a plus sign and this is the first I have heard that you could do it. 

Will try that.

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.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,150)