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

Newb Question - Does Patch function for the update of a record really require that you specify all required fields on a record even on an Update?

I have a gallery that pulls up existing associated Opportunity Products (records), allows the user to update some key fields using input fields, and then one button that does a ForAll for the gallery records to update the opportunity products with the updated values.

 

Patch seems to be requiring all the required fields. I know for a fact that these fields are already filled out (since they are required on create) and I am updating.  My current workaround is that I have to pull all of these fields into the Gallery, even if I'm not going to be changing them, and then include them in the Patch.

 

Let me show you an example of my code.  Note that confid % is one of the fields that is a hidden field on my gallery that I had to add because it's required, not one of the fields that the user is updating. Once I added this one, it stopped complaining about it and went to the next required field (also, already filled out). ClearCollect(GalleryRecords, AddColumns(WonScreenOppProductsGallery.AllItems ,"oppProdGUID", GUID(lblOppProductGuid.Text), "Confidence", Value(WonProductsConfidence.Text))); ForAll(GalleryRecords, Patch('Opportunity Products', LookUp('Opportunity Products', 'Opportunity Product'=oppProdGUID), {'Part Status':WonProductsPartStatusDropdown.Selected.Value, Competitor: WonProductsCompetitor.Selected, Comments: WonProductsComments.Text, 'DWIN/Lost Reason': ddWSPartStatusReason.Selected.Value, 'Confid %': Confidence}));

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

Yes, To patch an existing record or a new record you must list all the required fields in the patch.  For optional fields you are only required to list the ones you wish to update. But in general its not a best practice to have large numbers of required fields in SharePoint.  Doing that will tend to be a negative drag on user adoption.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Pstork1
Dual Super User
Dual Super User

Yes, To patch an existing record or a new record you must list all the required fields in the patch.  For optional fields you are only required to list the ones you wish to update. But in general its not a best practice to have large numbers of required fields in SharePoint.  Doing that will tend to be a negative drag on user adoption.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thanks - it's not SharePoint, it's Dynamics 365.  

The answer should be the same whether its SharePoint or CDS (Dynamics 365).



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I agree - the Patch function works the same, but the previous poster had said "Required fields in SharePoint are not advised". Whether or not they are, I don't think it's relevant to the question. No one is going to change required fields on their application just to make the Patch function easier to write.

Discouraging people from using required fields in SharePoint isn't because it makes Patch statements harder to write.  Minimizing the number of required fields is recommended in SharePoint because having an excessive number of required fields leads to poor user adoption.  Either way, any field that is required must be included in every Patch statement.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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
Top Kudoed Authors
Users online (4,868)