cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Please help me with the possibility?

Hi frds,

 

I want to create an powerapp using two sharepoint sharepoint list.

 

The scenario is i need to request for an equipment where i have to enter the spare parts and quantity and submit  the request.

 

in the First list I have to save the request details and in the second list i have to save the spareparts quntity wth reference to the Item ID.

 

There should be competable to edit the request as well.

 

--------------------------------------------------

Work I did till date was:

 

screen to request the order and adding the items with the quantity and saving the added item to the collection.

 

Now I have to submit the request with the submit button. should i need to use the path function?

 

If this is possible with the patch function please let me know the formula.

 

Please help me out with this.

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Microsoft
Microsoft

Hi Naresh,

 

 

So, if I understand you correctly, you need to capture the data first to one list and then, using a Unique reference to the data you just captured, capture other data to another list?

 

For this I use an EditForm with Submit and then a Patch - mainly because the Submit() function of a form will return the full record (including Source generated columns) and here I usually use the ID of the item just submitted, which you can then capture into your second list for a reference.

 

You can access the submitted record using the LastSubmit() function in the EditForm's OnSuccess property field.

So, assuming your second list had a reference column called "firstListRef" where you want to save the lookup from the first column - on the EditForm On Success property, you could submit a patch statement as follows;

 

EditForm1 OnSuccess:  

Patch(SecondList, 
	Defaults(SecondList), 
		{firstListRef: EditForm1.LastSubmit.ID, othercolumn: columndata})

 

This will then create a new row in the second list and capture the ID from the row submitted to the first list in firstListRef.

Not sure, but I think EditForm1.LastSubmit.ID could even just be LastSubmit.ID in the On Success property of the form - but if you're doing it somewhere else you could access it like that.

 

Hope this helps,


RT

 

View solution in original post

Highlighted
Community Support
Community Support

Hi @Naresh,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about the two SP lists that you mentioned?

 

I agree with @RusselThomas's thought almost. I created two SP lists on my side, the data structure as below:

First List ('20180704_case3_Requests'):3.JPG

Second List ('20180704_case3_Spareparts'):4.JPG

 Note: The RequestReference column is used to reference the Item ID from first list.

 

I have made a test on my side, please take a try with the following workaround:5.JPG

 

Set the Items property of the Edit form (Form1) to the first SP list data source.

 

Add a Button control (called "Submit") within the Edit screen, then set the OnSelect property to following formula:

SubmitForm(Form1)

Note: The Form1 represents the Edit form in the Edit screen.

 

Set the OnSuccess property of the Edit form (Form1) to following formula:

Patch(
'20180704_case3_Spareparts',
Defaults('20180704_case3_Spareparts'),
{
Title:"Spareparts Request From List1",
Spareparts_x0020_Name:Form1.LastSubmit.SparepartsName,
Spareparts_x0020_Quntity:Form1.LastSubmit.Quantity,
RequestReference:Form1.LastSubmit.ID
}
);
Back()

Note: The '20180704_case3_Spareparts' represents the second list. If there is a space within the column name of your SP list, please replace the space with '_x0020' within above formula (just as above formula mentioned). In addition, the Title column is a required field.

 

The GIF image as below:Test1.gif

 6.JPG

 

 

 

More details about Patch function in PowerApps, please check the following article:

Patch function

 

 

Best regards,

Kris

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Microsoft
Microsoft

Hi Naresh,

 

 

So, if I understand you correctly, you need to capture the data first to one list and then, using a Unique reference to the data you just captured, capture other data to another list?

 

For this I use an EditForm with Submit and then a Patch - mainly because the Submit() function of a form will return the full record (including Source generated columns) and here I usually use the ID of the item just submitted, which you can then capture into your second list for a reference.

 

You can access the submitted record using the LastSubmit() function in the EditForm's OnSuccess property field.

So, assuming your second list had a reference column called "firstListRef" where you want to save the lookup from the first column - on the EditForm On Success property, you could submit a patch statement as follows;

 

EditForm1 OnSuccess:  

Patch(SecondList, 
	Defaults(SecondList), 
		{firstListRef: EditForm1.LastSubmit.ID, othercolumn: columndata})

 

This will then create a new row in the second list and capture the ID from the row submitted to the first list in firstListRef.

Not sure, but I think EditForm1.LastSubmit.ID could even just be LastSubmit.ID in the On Success property of the form - but if you're doing it somewhere else you could access it like that.

 

Hope this helps,


RT

 

View solution in original post

Highlighted
Community Support
Community Support

Hi @Naresh,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about the two SP lists that you mentioned?

 

I agree with @RusselThomas's thought almost. I created two SP lists on my side, the data structure as below:

First List ('20180704_case3_Requests'):3.JPG

Second List ('20180704_case3_Spareparts'):4.JPG

 Note: The RequestReference column is used to reference the Item ID from first list.

 

I have made a test on my side, please take a try with the following workaround:5.JPG

 

Set the Items property of the Edit form (Form1) to the first SP list data source.

 

Add a Button control (called "Submit") within the Edit screen, then set the OnSelect property to following formula:

SubmitForm(Form1)

Note: The Form1 represents the Edit form in the Edit screen.

 

Set the OnSuccess property of the Edit form (Form1) to following formula:

Patch(
'20180704_case3_Spareparts',
Defaults('20180704_case3_Spareparts'),
{
Title:"Spareparts Request From List1",
Spareparts_x0020_Name:Form1.LastSubmit.SparepartsName,
Spareparts_x0020_Quntity:Form1.LastSubmit.Quantity,
RequestReference:Form1.LastSubmit.ID
}
);
Back()

Note: The '20180704_case3_Spareparts' represents the second list. If there is a space within the column name of your SP list, please replace the space with '_x0020' within above formula (just as above formula mentioned). In addition, the Title column is a required field.

 

The GIF image as below:Test1.gif

 6.JPG

 

 

 

More details about Patch function in PowerApps, please check the following article:

Patch function

 

 

Best regards,

Kris

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

HI @v-xida-msft@RusselThomas

 

Here is  the detailed of my work

 I have to fill the details of the following screen, then have to select the multiple items and store them in collection.

Finally will get back to this screen

On submission, the request to be submitted patching the collection values to a different list.

 

first i have to save the data into th sharepoint list.

patching the items please help me out.

 

ForAll(Collection1,Patch('Quantity master',Defaults('Quantity master'),{ProductID:EditForm1.LastSubmit.ID,Item ID:ItemID,Quantity:Qty})) 

 

 

Please help me out with this.

 

Capture1.PNG

Highlighted

Hi @RusselThomas@v-xida-msft

 

The issue has not resolved at I need to save the data into the SharePoint list.

 

I hope I need to write the patch function on the Submit.OnSelect Instead of Form1.OnSuccess.

 

If I m correct please help me with the formula.

 

I have to submit the form1 as well as the collection(ParentreferenceID,ItemID, Qty) to a different list.

Highlighted

Hi Naresh,

 

The LastSubmit() function will only be populated with data after a successful submission of data to the source.

This means it will not be available as part of the submission nor will it be populated if there are any errors.

 

This is why I load the patch statement into the OnSuccess property of the form.  It lso conveniently chains the action from your submit button through to the OnSuccess trigger, making sure you don't get a bunch of errors if for some reason you can't submit successfully.

 

That said, you can assume successful submission and attempt to patch as another command on the Submit button as you seem keen to do 🙂 ;

 

SubmitForm(Form1);
Patch(Form2, Defaults(Form2), {ProductID: Form1.LastSubmit.ID})

 

Just make sure you contruct your object property properly - should work fine, unless I'm missing what you're looking for.

 

Kind regards,

 

RT

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (13,180)