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}));
Solved! Go to Solution.
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.
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.
Thanks - it's not SharePoint, it's Dynamics 365.
The answer should be the same whether its SharePoint or CDS (Dynamics 365).
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.
User | Count |
---|---|
252 | |
107 | |
88 | |
51 | |
44 |