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

One form submits to two sharepoint lists

My form is attatched as an image below. I would like to submit all of these items to sharepoint_list_1. I would like to submit only Title, Corrective Action, and Action Owner to sharepoint_list_2. I am currently using a hidden form that automatically populates with the users info from the visible form and each form submits to one of the sharepoint lists. The issue arises in the edit page also attatched below, it can only edit sharepoint_list_1 that has all of the info input into it but needs to edit both. Is there another way to submit one form to both lists that would make editing them at the same time possible?

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
KrishnaV
Super User III
Super User III

Hi @Nick11 ,

 

Please remove the hidden form on the screen because that will increase the app complexity. Now on submit of the screen,

  1. SubmitForm(formname of the list1)
  2. Use Patch(SPlistName2,Defaults(SplistName2),{FiledName1:Val1,.......FieldNameN:ValueN})

for Edit also you can do the same.

  1. SubmitForm(formname of the list1)
  2. Use Patch(SPlistName2,lookup(SplistName2,ID=selectedID),{FiledName1:Val1,.......FieldNameN:ValueN})


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Make sure the column you set up for ParentID on your sharepoint list is a number column with zero decimal places. I know for sure the ID one is a number so it must be referring to your ParentID column.

 

Let me know if that does the trick.

View solution in original post

10 REPLIES 10
KrishnaV
Super User III
Super User III

Hi @Nick11 ,

 

Please remove the hidden form on the screen because that will increase the app complexity. Now on submit of the screen,

  1. SubmitForm(formname of the list1)
  2. Use Patch(SPlistName2,Defaults(SplistName2),{FiledName1:Val1,.......FieldNameN:ValueN})

for Edit also you can do the same.

  1. SubmitForm(formname of the list1)
  2. Use Patch(SPlistName2,lookup(SplistName2,ID=selectedID),{FiledName1:Val1,.......FieldNameN:ValueN})


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Nick11
Frequent Visitor

Attatched below is the formula I put into the submit button. It is only submitting this to the sharepoint list Form1 is attatched to not List2 that I tried to patch it to. What am I missing, is the formula supposed to be in a different location instead of the submit button, or is the formula itself wrong?

Do the SubmitForm() for the first list and then on that forms OnSuccess do your patch and you can have your fields refer to the first list for the values like- Title:Form1.LastSubmit.Title

 

 

Nick11
Frequent Visitor

While this helped greatly I am still having issues with the Edit function. When I try to use patch it does not edit the second sharepoint list becuase the IDs are different in each list and it is unable to find what to edit. The formula I have in the onselect of the edit form is 

Patch(List2,Lookup(List2,ID= Gallery1_1.Selected.ID),{Title:Form2.Lastsubmit.Title}) This is just to update the Title on List2.

How would you make it know what row to edit in List2 when the gallery is connected to the other sharepoint list and the IDs are different?

I normally do a tie field. So on list 2 you have a field that is a number one called ParentID and store the ID from List one in that column. Then you can use a lookup when you select an item from list one where it pulls the item in list 2 that has the ID from list one the same as the ParentID field in list 2. 

 

A few ways you can do it but that is my typical way.

Nick11
Frequent Visitor

I apoligize if this is a silly question but how do you create this tie field when there is already data in both sharepoint lists. How does the parentID in list2 know what ID it is supposed to match up with from list1?

You populate it when the item is created.

 

Form 1, List 1 - Button has SubmitForm(Form 1)

Form1 - OnSuccess = Patch(Creates item for list 2) and for the field ParentID you use ParentID:Form1.LastSubmit.ID

 

So the ID number for List 1 is created when you submit the form and then you carry that value over to List 2 with your patch. I use the ID a lot to tie my various list together (similar to how you would in Access) because it works well in PowerApps but it also works well over in PowerAutomate (Flow). The reason it does over there is because having the ID of the item will allow you to use the 'Get Item' instead of 'Get items' (with the s on end)...makes it much faster and more efficient. 

Nick11
Frequent Visitor

Sorry again for the trouble it makes sense and when i put the formula - 

Patch(List2,Defaults(List2),{ParentID:Form1.LastSubmit.ID}) I get an error message stating "The type of this argument 'ParentID' does not match the expected type 'Record'. Found type 'Number'.

Make sure the column you set up for ParentID on your sharepoint list is a number column with zero decimal places. I know for sure the ID one is a number so it must be referring to your ParentID column.

 

Let me know if that does the trick.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (62,951)