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

SharePoint "Customize List" with Patch - Issues with Save and Required Fields

I'm working on a Power App that someone else set up.  SharePoint list is the data source.  Patch function used. 

 

SharePoint Integration OnSave = 

 

If(
MainForm.Mode = New,
Set(varFlag,"1");
Patch(
'Project and Initiatives Control',
Defaults('Project and Initiatives Control'),
MainForm.Updates,
AddInfoForm.Updates,
StatusForm.Updates
),
Set(varFlag,"1");
Patch(
'Project and Initiatives Control',
{ID: SharePointIntegration.SelectedListItemID},
MainForm.Updates,
AddInfoForm.Updates,
StatusForm.Updates
)
);

 

With this set as-is, it shows errors for Required fields that are empty.  But, when click Save, the screen remains and doesn't close or go back to the list. 

 

If I add RequestHide() it saves and closes, but doesn't present errors for Required fields. 

 

How to fix?  Need to keep Patch, but also need errors for required fields and need the form to close/go back to list. 

 

TIA!

1 ACCEPTED SOLUTION

Accepted Solutions

@scnative ,

Why don't you just put a SubmitForm on a button on each form?

SharePointIntegration was never designed to do what you are attempting. If you do them one at a time, any required fields will be flagged. Also, have you tried the suggestion I made to look for blank fields before submitting the code?

 

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.

View solution in original post

10 REPLIES 10
WarrenBelz
Super User
Super User

Hi @scnative ,

From my understanding required fields are triggered generally by SubmitForm or in the case of a new record using Patch, the data simply will not save to the data source. The problem with using the integrated save is that it was not (I believe) ever designed to perform this level of modification.

One solution would be to code in the required fields before the Patch

If(
   IsBlank(ControlValue),
   Notify("Field is required"),
   Patch . . . .
)

 

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.

@WarrenBelz - so theoretically, if I create a button to submitform, it would achieve what I want?

Hi @scnative ,

That is what the Standard "out of the box" OnSave event in SharePointIntegration does and yes, SubmitForm takes care of required fields and if the control is left standard, it also displays the error.

 

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.

 

 

@WarrenBelz - sorry, I mean given the current Patch scenario, using a SubmitForm button at the bottom of the screen would achieve it?

I tried SubmitForm button and it closes the form if I add RequestHide(), but doesn't prompt for required fields.  This is very frustrating. 

@scnative ,

Why don't you just put a SubmitForm on a button on each form?

SharePointIntegration was never designed to do what you are attempting. If you do them one at a time, any required fields will be flagged. Also, have you tried the suggestion I made to look for blank fields before submitting the code?

 

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.

View solution in original post

Hi @scnative ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

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.

Hi @WarrenBelz, I haven't yet tried the check for blank fields yet because we have over 60 fields and it seems a bit clunky to create code to individually check all 60 fields. 

HI @scnative ,

Maybe you should consider using SubmitForm() on them individually before moving off them - it would than all work. There is really no other solution than these two.

 

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.

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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