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

Patching columns to SP library from Powerapps

Hi All,

     I've got an app that links to a SP library as a data source ( I want a library rather than a list as I have a populate word document flow linked to the library that I want to keep). I've tried all sorts to patch the forms to the library with not a lot of success, so am trying to patch the individual tables to the library columns instead. 

    The data cards are all linked to the SP library 'Risk Assessments', some of the columns are choice, some single line text, some multi text, 1 date, and others pull data from datacards elsewhere in the app.

    Through research it looked like I could get away with the below, but I get the error that I need to use SPFileCollection.Add(), so I guess the question is, is it possible to patch datacards to a SP datasource(library), or will I need to create a library of lookup columns and link them to a list?

   Would appreciate anyone being able to have a look at the below and see if there's anything glaring that I've missed? 

 

Thanks

 

Patch('Risk Assessments',
{'Job Type':DataCardValue66.Selected.Value},
{'Activity':DataCardValue35.Text},
{'Team members': DataCardValue58.SelectedItems}, {'Date': DataCardValue31.SelectedDate},
{'Task Location':DataCardValue32.Text},
{'Task 1': DataCardValue33.Text},
{'Task 1 Hazards':DataCardValue36.SelectedItems},
{'Task 1 existing controls': DataCardValue37.SelectedItems},
{'Task 1 consequence': DataCardValue55.Selected},
{'Task 1 likelihood': DataCardValue59.Selected},
{'Task 1 additional controls': DataCardValue42.Text},
{'Task 1 residual consequence':DataCardValue56.Selected},
{'Task 1 residual likelihood':DataCardValue57.Selected});

1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Super User
Super User

Hi @JLaw973 ,

 

The central item of a document library record is the File /Folder itself, or in your case it seems that this important piece is missing. You'll have no problem to update the columns of a record (if the file is already exist in document library), but you cannot create a new record in document library if don't suply the file and this is not posible right now from PowerApps.

 

You can find over the internet some great videos about how to upload a file using PowerApps and PowerAutomate.

 

So ... I think you should reconsider your solution and adopt a Sharepoint list as database and keep your file doc as item's attachament.

 

On the other hand, please note that the  Patch syntax to update an item is :

Patch(DataSource, Item from DataSource, {Column1:Value,Column2:Value, ....})

and to create a new item:

Patch(DataSource, Defaults (DataSource), {Column1:Value,Column2:Value, ....})

 

So I think that if you want to update an item in the list your code has to be similar to:

Patch('Risk Assessments',LookUp('Risk Assessments', .... ),
{'Job Type':DataCardValue66.Selected.Value},
Activity':DataCardValue35.Text,
'Team members': DataCardValue58.SelectedItems, 'Date': DataCardValue31.SelectedDate,
'Task Location':DataCardValue32.Text,
'Task 1': DataCardValue33.Text,
'Task 1 Hazards':DataCardValue36.SelectedItems,
'Task 1 existing controls': DataCardValue37.SelectedItems,
'Task 1 consequence': DataCardValue55.Selected,
'Task 1 likelihood': DataCardValue59.Selected,
'Task 1 additional controls': DataCardValue42.Text,
'Task 1 residual consequence':DataCardValue56.Selected,
'Task 1 residual likelihood':DataCardValue57.Selected})

 

Hope it helps !

View solution in original post

2 REPLIES 2
gabibalaban
Super User
Super User

Hi @JLaw973 ,

 

The central item of a document library record is the File /Folder itself, or in your case it seems that this important piece is missing. You'll have no problem to update the columns of a record (if the file is already exist in document library), but you cannot create a new record in document library if don't suply the file and this is not posible right now from PowerApps.

 

You can find over the internet some great videos about how to upload a file using PowerApps and PowerAutomate.

 

So ... I think you should reconsider your solution and adopt a Sharepoint list as database and keep your file doc as item's attachament.

 

On the other hand, please note that the  Patch syntax to update an item is :

Patch(DataSource, Item from DataSource, {Column1:Value,Column2:Value, ....})

and to create a new item:

Patch(DataSource, Defaults (DataSource), {Column1:Value,Column2:Value, ....})

 

So I think that if you want to update an item in the list your code has to be similar to:

Patch('Risk Assessments',LookUp('Risk Assessments', .... ),
{'Job Type':DataCardValue66.Selected.Value},
Activity':DataCardValue35.Text,
'Team members': DataCardValue58.SelectedItems, 'Date': DataCardValue31.SelectedDate,
'Task Location':DataCardValue32.Text,
'Task 1': DataCardValue33.Text,
'Task 1 Hazards':DataCardValue36.SelectedItems,
'Task 1 existing controls': DataCardValue37.SelectedItems,
'Task 1 consequence': DataCardValue55.Selected,
'Task 1 likelihood': DataCardValue59.Selected,
'Task 1 additional controls': DataCardValue42.Text,
'Task 1 residual consequence':DataCardValue56.Selected,
'Task 1 residual likelihood':DataCardValue57.Selected})

 

Hope it helps !

View solution in original post

Hi @gabibalaban

         Thanks for your help, I was hoping that it was possible just to update the columns in a library without the doc being submitted as well, as the app is a mobile app I don't think it's feasible to update the template in the library, so as you say, will need to find another way!

     Thanks for taking the time to have a look.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,633)