cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
adstar22
Level: Powered On

Sharepoint List record update FROM powerapps collection - or multiple forms

I am really struggling with a utility which displays varying pieces of information across multiple forms/screens, navigated dependent on user selection.

 

My objective is to have a new item or modified item trigger a workflow.

 

During my trial and development, I have been able to update a sharepoint entry by using the formsubmit command. But I would have to do that for each page of the form it seams. when what I REALLY want to be able to do, is

a) collect data from the forms/screens into a collection

b) submit the new item or updated item as a single "event" which triggers the workflow(s)

 

I have managed to create my collection (colItem), and extracted data into it.

I can differentiate between a new and existing item based on the presence of an ID (First(colItem).ID)

 

But, what I am currently able to do is:

1) Identify the matching sharepoint record, based on the ID (struggling with syntax)

2) update or Patch the submitted changes from my collection into my list

 

Code I have tried:

If(IsEmpty(colItem.UID),"true",Patch('Sys Inventory AW',First(Filter('Sys Inventory AW',ID=First(colItem).UID))))

If(IsEmpty(colItem.UID),"true",Update('Sys Inventory AW',Filter('Sys Inventory AW',ID=First(colItem.UID)),First(colItem)))

 

Where colItem is my collection

UID is the item ID in my collection

Sys Inventory AW is my sharepoint list

ID is the item ID in sharepoint

 

I think I'm am on the right track (I hope) but I am REALLY struggling with the syntax.

I am also wondering if I am referring to the collection correctly. But that is another issue for another day!

1 ACCEPTED SOLUTION

Accepted Solutions
adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Problem solved! At last!!! Although... I now feel that the heading for this post is going to be miss leading! I will have to try and change it.

 

This is a limitation in my knowledge/understanding for how powerapps works and what the commands do, vs what they say!

 

It turns out, based on some research I did triggered by the replies above, that you can submit UPDATES from multiple forms as part of a patch. AND.. if you don't wrap them in curly brackets {} it is all a single entry on the list!!!

 

So my now fully functioning code reads:

If(Form1.Mode=New,Patch('Sys Inventory AW',Defaults('Sys Inventory AW'),EditForm1.Updates,Form1.Updates),Patch('Sys Inventory AW',BrowseGallery1.Selected,EditForm1.Updates,Form1.Updates));Navigate(BrowseScreen1,Fade)

 

This negates the need for me to interact with the drop down list codes and records or anything clever like that! It just applies what I have selected to the appropriate fields in my sharepoint list!

 

I feel so stupid... but I am also over the moon that I have succeeded in resolving this because it means I can progress my project to completion.. no doubt encountering another little issues along the way!

View solution in original post

10 REPLIES 10
Community Support Team
Community Support Team

Re: Sharepoint List record update FROM powerapps collection

Hi @adstar22,

 

Mr-dang has a good posts regarding patch collection to SharePoint list, please check and see if it would help:

Patch a collection of items to SharePoint

For trigger the workflow, add the flow.run() behind the Patch() function.

If you need any further help on this, please post back.

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Hi,

Thanks for the reply.

I have moved on from trying to patch from collections, to trying to patch directly from forms. And I am having the same type of issue with the syntax, and identifying my record in sharepoint.

 

I check for the presence of an ID in a different context field, and this allows me to display 'form1' in new mode.

 

Currently I am trying:

 

If(Form1.Mode=New,SubmitForm(EditForm1);UpdateContext({cvID:Last('Sys Inventory AW').ID});Patch('Sys Inventory AW',First(Filter('Sys Inventory AW',ID=cvID)),{Business_x0020_Impact:BusinessImpact},{Business_x0020_Impact_x0020_Justification:BusinessImpactJustification}),Patch('Sys Inventory AW',BrowseGallery1.Selected,EditForm1.Updates,Form1.Updates));Navigate(BrowseScreen1,Fade)

 

Currently, the SubmitForm(EditForm1) works, and creates a new entry in the sharepoint list (Sys Inventory AW) based on the first entry form I display.

 

Based on all the patching instructions I have read, and because I cant use SubmitForm(Form1) (the second form I display) because it isnt "attached" to the same sharepoint record, I try and extract the new sharepoint entry ID into a context variable.

 

I think try to use the context variable to filter the sharepoint list for the matching ID, which I then patch records into... accept.. nothing seems to work from the second form!

 

It is the same as my original query... I dont appear to be able to identify the NEW sharepoint record I want to update. Solving this syntax issue would resolve all my other problems and enable me to make rapid prrogress.

 

Annoyingly... I CAN update and existing sharepoint record using the command above!!!

morgade1
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Have you tried to do a refresh(table) command before doing your intended update?

adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Hi all,

 

Yes I have refreshed the table.

 

Current code:

If(Form1.Mode=New,SubmitForm(EditForm1);Refresh('Sys Inventory AW');Patch('Sys Inventory AW',Last('Sys Inventory AW'),{Business_x0020_Impact:BusinessImpact.Selected},{Business_x0020_Impact_x0020_Justification:BusinessImpactJustification},{Compliance_x0020_Status:CompStatus.Text}),Patch('Sys Inventory AW',BrowseGallery1.Selected,EditForm1.Updates,Form1.Updates));Navigate(BrowseScreen1,Fade)

 

I thought I would try and patch something really basic: 'a single line of text' as described/defined by sharepoint. This is the highlighted command above.

 

Unlike the other fields in my patch command (business impact is a lookup field and Business Impact Justification is a multiple line of text) the Compliance Status is a single line of text.

 

What I have estabilshed now, is that i HAVE accessed the correct record in sharepoint. But my patch command is not correct due to the field types - possibly??

 

I say this because the Compliance Status field IS updated for the new record.

 

The problem now, is that it only updates the entry with the default value! If I change the entry on the powerapps form... it still applies the default value to the sharepoint list!!!

 

2 steps forwards 1 step back!

Community Support Team
Community Support Team

Re: Sharepoint List record update FROM powerapps collection

Hi @adstar22,

 

Your code:

 

If(Form1.Mode=New,
   SubmitForm(EditForm1);
     Refresh('Sys Inventory AW');
     Patch('Sys Inventory AW',
Last('Sys Inventory AW'), {Business_x0020_Impact:BusinessImpact.Selected}, {Business_x0020_Impact_x0020_Justification:BusinessImpactJustification}, {Compliance_x0020_Status:CompStatus.Text}), Patch('Sys Inventory AW', BrowseGallery1.Selected, EditForm1.Updates, Form1.Updates) ); Navigate(BrowseScreen1,Fade) )

Could you please explain a bit for the bold part?

 

For your first Patch function:

Patch('Sys Inventory AW',
Last('Sys Inventory AW'), {Business_x0020_Impact:BusinessImpact.Selected}, {Business_x0020_Impact_x0020_Justification:BusinessImpactJustification}, {Compliance_x0020_Status:CompStatus.Text}),

Do the three {} mean three different records? 

If you need to update three fields in the baseRecord (here means the Last('Sys Inventory AW')), we could write the formula in the following way:

Patch('Sys Inventory AW',
Last('Sys Inventory AW'), {Business_x0020_Impact:BusinessImpact.Selected, Business_x0020_Impact_x0020_Justification:BusinessImpactJustification, Compliance_x0020_Status:CompStatus.Text}),

 

Have you tried to replace the ComStatus.Text with the following?

Editform.LastSubmit.Compliance_x0020_Status

 

Please check and see if this would work.

Besides, for the error about type mistach, would you please share the error message here?

By using patch, there are fields that you must specify in the record, such as Title, which has been marked as unique (or the field marked with * in EditScreen ) in SharePoint list.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Hi Michael,

I appreciate your time/assistance with this. Here we are all thinking that this shouldnt be as difficult as we are finding it!

I shall try and add more information as requested:

 

Because we will eventually be submitting a LOT of data to a single record on the sharepoint list, I have to split the data onto different screens, and in this example forms. To submit a "complete" new record to my sharepoint list I SubmitForm(EditForm1) which creates a new entry on the sharepoint list, with the details from the first screen.

 

The first patch function is required (I believe) because at the point I access Form1 on screen 2, in NEW mode, the record doesnt exist in sharepoint (hence the new mode). I am workign on the thoery that when the user is happy with all the data they want to enter.. they do so in one go. This should give me greater control for error handling, version control of entries, and triggering workflows.

 

You are correct about the extract {...} I miss understood the sytax and have corrected it.

 

Business_x0020_Impact is a column on my Sharepoint List. It is a lookup on the list referring to a seperate sharepoint list. The auto generated field/entry is displayed on datacard15 on form1.

BusinessImpact is the drop down list from which the user selects an item the want to "apply" /choose to the new entry. It displays the items from the same seperate Sharepoint List.

I was expecting to submit/retain the value selected in the drop down in my Sys Inventory AW list. But keep getting issues with how to patch a drop down into a drop down I think. An alternative is to make change my Sys Inventory list to a basic text field, and get powerapps to use a drop down list to populate it. But it should be possible as it is!

 

Business_x0020_Impact_x0020_Justification is a multiple lines of text field on my sharepoint list. I havent modified the default datacard which powerapps should be using to apply entries in this field to the sharepoint list. However... Not only am I not able to use the return key to create multiple lines of text... nothing is submitted to the sharepoint list!

 

The second patch function is used when editting a record using the same form(s) in Edit mode... and this all seems to work fine!

 

I have looked into and tried your final suggestion... but editform.lastsubmit didnt/doesnt work.. my guess is because the forms are in new mode, and it looks like this command is for forms in editmode?

adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection or multiple forms

Problem solved! At last!!!

 

This is a limitation in my knowledge/understanding for how powerapps works and what the commands do, vs what they say!

 

It turns out, based on some reasearch I did triggered by the replies above, that you can submit UPDATES from multiple forms as part of a patch. AND.. if you dont wrap them in curly brackets {} it is all a single entry on the list!!!

 

So my now fully functioning code reads:

If(Form1.Mode=New,Patch('Sys Inventory AW',Defaults('Sys Inventory AW'),EditForm1.Updates,Form1.Updates),Patch('Sys Inventory AW',BrowseGallery1.Selected,EditForm1.Updates,Form1.Updates));Navigate(BrowseScreen1,Fade)

 

This negates the need for me to interact with the drop down list codes and records or anythgin clever like that! It just applies what I have selected to the approariate fields in my sharepoint list!

 

I feel so stupid... but I am also over the moon that I have succeded in resolving this because it means I can progress my project to compleation.. no doubt encountering another of other little issues along the way!

adstar22
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Problem solved! At last!!! Although... I now feel that the heading for this post is going to be miss leading! I will have to try and change it.

 

This is a limitation in my knowledge/understanding for how powerapps works and what the commands do, vs what they say!

 

It turns out, based on some research I did triggered by the replies above, that you can submit UPDATES from multiple forms as part of a patch. AND.. if you don't wrap them in curly brackets {} it is all a single entry on the list!!!

 

So my now fully functioning code reads:

If(Form1.Mode=New,Patch('Sys Inventory AW',Defaults('Sys Inventory AW'),EditForm1.Updates,Form1.Updates),Patch('Sys Inventory AW',BrowseGallery1.Selected,EditForm1.Updates,Form1.Updates));Navigate(BrowseScreen1,Fade)

 

This negates the need for me to interact with the drop down list codes and records or anything clever like that! It just applies what I have selected to the appropriate fields in my sharepoint list!

 

I feel so stupid... but I am also over the moon that I have succeeded in resolving this because it means I can progress my project to completion.. no doubt encountering another little issues along the way!

View solution in original post

ldurland
Level: Powered On

Re: Sharepoint List record update FROM powerapps collection

Update: I did get this resolved. not sure how or if it was just a glitch in powerapps but it is working as it should.

 

hoping to resurect this post. I am in the same boat and while i can submit new when i try and update and submit i get an error

 

"Modified:The specified column is generated by the server and cant be specified"

 

I am assuming that it is referring to the modified column in the data source (sharepoint list standard column) I am not using it at all in my app so i am stumped.

 

Any ideas? has the method changed since this worked?

 

Thanks

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,655)