cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Patch Not Working Now?

I am still new to Power Apps and having issues with a patch not working. It works fine in another form and worked fine once on this new form, then stopped working altogether? It does not show any errors. Here is my code below. I would appreciate any advice. Thanks!

 

 

UpdateContext({locShowSpinner: true});
If(IsBlank(DataCardValue87.Selected.Value), UpdateContext({IsError15: true}));
If(IsBlank(DataCardValue90.Selected.Value), UpdateContext({IsError16: true}));
If(IsBlank(DataCardValue99.Text), UpdateContext({IsError17: true}));
If(IsBlank(DataCardValue96.Text), UpdateContext({IsError18: true}));
If(IsBlank(DataCardValue97.Text), UpdateContext({IsError19: true}));
If(Not(IsError15 || IsError16 || IsError17 || IsError18 || IsError19),
Patch(
    FuelLogRentalEquipmentList,
    Defaults(FuelLogRentalEquipmentList),
    {
        Title:DataCardValue67.Text,
        EquipmentCategory:DataCardValue70.Text,
        EquipmentNo:DataCardValue88.Text,
        RentalCompany:DataCardValue89.Text,
        Year:DataCardValue99.Text,
        Make:DataCardValue96.Text,
        Model:DataCardValue97.Text,
        SerialNoVIN:DataCardValue98.Text,
        Photo:Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """","")
    };
    Rental_AddNewEquipForm.Updates
));
Refresh(FuelLogRentalEquipmentList);
ClearCollect(RentalEquipList, FuelLogRentalEquipmentList);
If(Not(IsError15 || IsError16 || IsError17 || IsError18 || IsError19),
ResetForm(Rental_AddNewEquipForm)&
Navigate(RentalEquipScanGallery,ScreenTransition.Fade));
UpdateContext({locShowSpinner: false});

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@Patrick-Stamper 

Yes, you don't want to use a patch on the form as much as possible.  This completely defeats the purpose and value of the forms.  They provide a tremendous amount of functionality that you negate when you use patch on it.

 

Your problem then comes from the fact that you need to use the JSON function and that is something that must be done in a behavioral action.

So, as a quick "how to", you can change your Submit action formula to:

 

UpdateContext({lclPhotoValue: Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """", "")});
SubmitForm(Rental_AddNewEquipForm)

 

And then, for the Update property on the DataCard for the field - Photo, set the formula to:

lclPhotoValue

 

This will cause the behavioral function JSON to evaluate in the proper type of formula and the form will then reflect that data for the update values for the SubmitForm function.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@Patrick-Stamper 

Actually...to fill out your Submit action a little more based on your original formula...it would be like this:

UpdateContext({locShowSpinner: true});
If(Rental_AddNewEquipForm.Valid,
    UpdateContext({lclPhotoValue: Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """", "")});
    SubmitForm(Rental_AddNewEquipForm)
)

 

Then in your OnSuccess action of the Form, the following formula:

ResetForm(Rental_AddNewEquipForm);
Navigate(RentalEquipScanGallery,ScreenTransition.Fade));
UpdateContext({locShowSpinner: false});

 

There is no need to do a Refresh on a Datasource that you just updated...it will already have the refreshed/current values in it.  Doing the refresh just slows down the app.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@Patrick-Stamper 

You appear to be using a Form (Rental_AddNewEquipForm).  So the question is...why are you Patching??  You should be using the SubmitForm function on your form to submit the data.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Because of:

Photo:Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """","")

, does not seem to work with just SubmitForm?

 

Cristian_Moraru
New Member

It looks like you have an extra parameter in the Patch function. 

;
    Rental_AddNewEquipForm.Updates

What are you trying to do with that parameter in the Patch function?

I'm still new to Power Apps, I read that on a forum to add attachments.

RandyHayes
Super User
Super User

@Patrick-Stamper 

Yes, you don't want to use a patch on the form as much as possible.  This completely defeats the purpose and value of the forms.  They provide a tremendous amount of functionality that you negate when you use patch on it.

 

Your problem then comes from the fact that you need to use the JSON function and that is something that must be done in a behavioral action.

So, as a quick "how to", you can change your Submit action formula to:

 

UpdateContext({lclPhotoValue: Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """", "")});
SubmitForm(Rental_AddNewEquipForm)

 

And then, for the Update property on the DataCard for the field - Photo, set the formula to:

lclPhotoValue

 

This will cause the behavioral function JSON to evaluate in the proper type of formula and the form will then reflect that data for the update values for the SubmitForm function.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

That worked FLAWLESSLY!!! Thanks for your help!! Just had to remove the parenthesis curve bracket behind ".image".

RandyHayes
Super User
Super User

@Patrick-Stamper 

Oops, yes...I threw in a bonus closing paren 😉

I have edited it above to be correct.

Glad it worked for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
RandyHayes
Super User
Super User

@Patrick-Stamper 

Actually...to fill out your Submit action a little more based on your original formula...it would be like this:

UpdateContext({locShowSpinner: true});
If(Rental_AddNewEquipForm.Valid,
    UpdateContext({lclPhotoValue: Substitute(JSON(UploadedImage3.Image, IncludeBinaryData), """", "")});
    SubmitForm(Rental_AddNewEquipForm)
)

 

Then in your OnSuccess action of the Form, the following formula:

ResetForm(Rental_AddNewEquipForm);
Navigate(RentalEquipScanGallery,ScreenTransition.Fade));
UpdateContext({locShowSpinner: false});

 

There is no need to do a Refresh on a Datasource that you just updated...it will already have the refreshed/current values in it.  Doing the refresh just slows down the app.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Awesome! You are the Man! I learned some good stuff here today. I also did not know about the Refresh ordeal. Thanks again Randy!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,472)