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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Editing and saving Sha...
Power Apps
Unanswered

Editing and saving Sharepoint Form creates new item in list

(0) ShareShare
ReportReport
Posted on by 22

I am creating a power apps form that has multiple edit forms inside. When I create a new list item using the form in sharepoint it saves fine. But when I try to edit and save an existing list item, it will create a new item. I was wondering if there was some conditional logic that can be used on the "onEdit" section to fix this problem. Any suggestions or information would be greatly appreciated.

Below is the list of setting under Sharepoint Integration 

care's1.png

The following is what occurs when I edit the first item, causing it to create a new item.

Care's.png

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jokanol1 

    This is all going to be based on how you connect these forms together and how you submit them.

    You are using a Patch statement to connect them and you are specifying Defaults in the OnSave.  This is going to create a new item.  

    You should be working with only one master form in your app.  You can have as many child forms as you want. 

    I have a video on how to split forms on multiple screens that I highly recommend you watch.  It does not specifically address SharePoint Integration, but the concept is exactly the same.  I would be happy to answer any questions about that method and integration as I believe this will be highly successful for you rather than throwing away all the features of the form by using a Patch.

     

    I hope this is helpful for you.

  • jokanol1 Profile Picture
    22 on at

    @RandyHayes 

    Thank you for your response. I just watched your video and it was very informative and I believe it may work. One point of clarification for my specific predicament.  

    In your video, you have a master screen which houses all the cards that are part of the overall form. In my case, I have 100+ datacards throughout my different tabs. For your solution, would I have to include and format all the cards on the "master" screen in order for this to work? 

    I have attached a few pictures of what my form currently looks like.

    dba.png

    info steps.png

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jokanol1 

    On your master form, you would need to include all of the fields.  For any field that is already included in another form, just set the Visible property of that datacard to false.  There is nothing more you need to do to it.

    The only reason you need all of them is that the Updates property (and what SubmitForm writes back) is based on all of the fields in your form.  If you don't have a field in the form, even if it is in the Item property of the form, it will not get written.  So, yes, all the fields and all the ones from other forms set Visible to false.

  • jokanol1 Profile Picture
    22 on at

    @RandyHayes 

    First off, thank you for your responses.

     

    From what I am understanding, I would just need to include all the datacards from the various forms into the master and set the visibility to false. Since I am doing Sharepoint Integration, I would set the glbVariable to the SPI connection. Then I would use Patch(glbVariable, Form1.updates (master form), Form2.updates (child form), Form3.updates(child form)...etc). Is my understanding correct?

     

    Is the master form simply the place the data is stored? Or do I need to format the datacards to be the same as the datacards from the other tabs? Take my current form. I have a editform with "Clients Name" and "Status" as the datacards. Could I just use this as the master by adding all the other data cards from this screen as well as the others and set the visibility to false to this form? 

     

    Finally since I am doing SPI, would the "onSave" "onEdit" etc from SPI have the glbVariable in the field or is there other logic that I have to put into it? Also, I may not be understanding the use of the glbVariable if everything is being saved on the master form.

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jokanol1 

    No, you would not use Patch directly.  This completely misses the value of the form.

    Your Master form would have an Item property of Patch(glbCurrentItem, Form1.Updates, Form2.Updates, etc...)

    Ultimately you would be doing a SubmitForm(yourMasterForm)

    The Item property above is what joins all the other forms to the master.

    For the master form, there is nothing that needs to be formatted or changed in regard to the datacards from the other forms except to change the Visible to false.  Again, they are only there because the need to participate in the record Updates of the final SubmitForm.  They should not be modified except as to change the Visible to false.

     

    The global variable should be set as follows (I'm calling it glbCurrentItem because I don't recall what I called it in the video, but same thing) in the SharePoint Integration:

    OnNew : Set(glbCurrentItem, Defaults(yourListName)); EditForm(Form1)

    OnEdit : Set(glbCurrentItem, SharePointIntegration.Selected); EditForm(Form1)

    OnView: Set(glbCurrentItem, SharePointIntegration); ViewForm(Form1)

    OnCancel Set(glbCurrentItem, Blank()); ResetForm(yourMasterForm)

     OnSave : SubmitForm(yourMasterForm)

     

    The OnSuccess action  of your master form should be : ResetForm(yourMasterForm); RequestHide()

    The OnReset action of your master form should be: Reset(Form1); Reset(Form1_1)....etc...

     

    Nothing else is needed.

  • jokanol1 Profile Picture
    22 on at

    @RandyHayes 

    is the button required to set the global variable? Since I am going to be using SP, I was hoping not to need submit and create new items on the actual form itself. I was going to use the "new" and edit buttons built into the sharepoint in the modernview.

     

    Also on the SPI section, for the"Set(glbCurrentItem, Defaults(yourListName)); EditForm(Form1))"  and other parts, does the "editform(Form1)" need to be the first form (and only the first) or can it be any form? Im guessing its not any but the master if not im not mistaken.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jokanol1 

    You do not need a button for anything.  The last reply I gave you all the formula you need on the On.xxx actions of the SharePoint integration object.  Those will do everything that was done with a button in the video.

     

    You really don't need the EditForm if your form has the default mode set to Edit.

    However, if you want to provide a View only capability, then keep it in there.  It can be any form, but I suggest the master form be the one you use.  

    I believe I mentioned in the video, all of the DefaultMode properties of all of the other forms should reference the masterform Mode.  This will make sure that all forms are in the same mode all the time.

    Then, everything that is done in the formulas I gave you for the On.xxx Actions will work properly.

  • jokanol1 Profile Picture
    22 on at

    @RandyHayes 

    So the solution no longer creates a new item every time i edit and save, which is good. However, the form on the sharepoint edit/preview part is no longer displaying the data from the columns. 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jokanol1 

    Ooops, if you used my formula on the OnView, I see there is a typo there.  Should be:

    Set(glbCurrentItem, SharePointIntegration.Selected); ViewForm(Form1)

  • jokanol1 Profile Picture
    22 on at

    @RandyHayes 

    I changed it, however, the problem still persists. The data is going to the columns in the SP list, but for whatever reason, the preview does not display the data for that SP item. Any other suggestions?

     

    Also, I just checked and the data from my other tabs are not being saved. Only data on the first tab is saving. I checked to make sure I have the datacards from the other tabs in the master_form and I do. Also, i checked the form mode and its set to master mode. Any suggestions for this problem as well?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard