web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch function with Fo...
Power Apps
Unanswered

Patch function with Form.Updates only saving some fields to SharePoint but not others

(0) ShareShare
ReportReport
Posted on by 13

Hi, I have been creating an application form submission app. For the Submit button I used a Patch function with a mix of Form.Updates and explicitly mentioning the updates in curly braces. The Patch function is quite long and I have used many If statements within it.

 

Up until recently, whenever I submitted the form, the data would be saved to SharePoint as expected. However, recently, after adding many of the said If statements, the form saves the data from some fields but not others. There are no errors shown, and I have combed through the code several times. Not sure if this issue is due to me making the Patch statement too complex, or is a bug, or a mistake of mine.

Categories:
I have the same question (0)
  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    It's possible that the issue you're experiencing is related to the complexity of your Patch function or how you're using the Form.Updates function and curly braces to explicitly mention updates. Without seeing your actual code, it's difficult to pinpoint the exact problem. However, I can provide some general suggestions to help you troubleshoot and potentially resolve the issue:

    1. Verify the If statements: Since you mentioned using multiple If statements within the Patch function, double-check if the conditions in these statements are correctly evaluating the fields you want to save. Ensure that the logic within the If statements is accurate and that all relevant fields are being considered.

    2. Check the Patch syntax: Make sure the Patch function is properly constructed and that you are passing the correct parameters. Check the SharePoint column names and the corresponding fields in your form to ensure they match correctly. Any mismatch in column names or form field references can result in data not being saved as expected.

    3. Debug with logging: Consider adding logging statements within your Patch function to track the values of variables and fields at different stages of execution. This can help you identify any unexpected behavior or discrepancies that may occur during runtime.

    4. Simplify the Patch function: If the complexity of your Patch function is causing difficulties in identifying the issue, you can try simplifying it by removing some of the If statements temporarily. Test the simplified version to see if it saves the data properly. Then gradually reintroduce the If statements one by one, testing after each addition to pinpoint the problem area.

    5. Test individual fields: To isolate the problem, try submitting the form with only one field at a time and verify if it gets saved to SharePoint correctly. This can help you identify whether the issue lies with specific fields or if it is a more general problem.

    6. Review recent changes: If the issue appeared after adding the If statements, carefully review the changes you made. Check if any recent modifications could have inadvertently affected the behavior of the Patch function or the way form updates are handled.

    7. Consider SharePoint limitations: Keep in mind any limitations or restrictions imposed by SharePoint, such as character limits or data type constraints. Ensure that the data being passed to SharePoint adheres to these requirements.

    If you're still unable to resolve the issue, it would be helpful to provide the actual code you're using, along with any error messages or specific details about the fields that are not being saved. With more information, I can offer more targeted guidance.

  • jtsdev063 Profile Picture
    13 on at

    Hi Shaheer,

     

    Thanks for the guidance. Will look into it myself first, if I still have trouble, I'll upload the code.

  • jtsdev063 Profile Picture
    13 on at

    Hi Shaheer, I did some testing and it seems that the issue is with this bit of code:

     

    jtsdev063_0-1686547450202.png

     

    The issue was that the data from some forms were not being saved to SharePoint, for example 'Part2ATeamMember1_Form' and similar forms following it. While the data from the fields in that form did not get saved, varPolicyMember1Blob did get saved to the column 'Policy Member 1 Signature'.

     

    When I commented out the line shown in the picture, this time the data in the form did get saved (and of course the signature didn't get saved this time).

     

    Those 2nd line is affecting the first somehow, but there is no syntax error highlighted...

  • Verified answer
    jtsdev063 Profile Picture
    13 on at

    Hi, just an update on the issue I was facing.

     

    I managed to fix it, the problem was that I had multiple update statements within If statements which were in turn within the Patch function. For a Patch function, different update statements are separated by commas. However, as conditions using If statements were involved, I could not use commas as that would make the update statement following it go into the If statement's false value parameter. So I tried to chain the update statements using semi-colons instead. I learnt now that if you do that, only the first update statement will be executed, and subsequent ones won't. I had to modify my code so that I could use commas in between the update statements again.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard