Upload a File to Sharepoint With Column Names C#
SharePoint helps users to finer manage their contents with Lists and Libraries. Lists are meant for creating items and then tin attach external files to it, only on the other hand Libraries are but for creating predefined doc sets or to upload a file. A file is considered as 1 item and no further files can be added to the same item in a document library.
Consider a scenario where your vendor wants to maintain a document library with all the contents uploaded to that library and a supporting email attachment/pdfs/images attached to the same file uploaded as proof of show. Now the requirement is valid so yous cannot get stuck to the limits rather obtain a solution outside of information technology.
Solution using Power Platform
Convert your SharePoint library from default course to PowerApps class and Edit the form in PowerApps designer. And then borrow the attachments command from any of the SharePoint lists because it supports multiple file attachments and a preview section. Store them in a drove and upload the file to a different SharePoint library with a Foreign Key as a reference using Power Automate flow. Create a new Gallery Control in the same course to brandish the files uploaded. Optionally the file uploaded can besides exist deleted past using another simple flow. Voila! The objective is fulfilled!
At present let'due south encounter how to accomplish this stride by step
Create two libraries in my SharePoint site collection
- Vendor Documents: to collect files from the vendor
- VendorDocAttachments: to upload files for each particular in the vendor documents
Columns to exist created,
| Library Name | Column Proper noun | Type | Remarks |
| Vendor Documents | UploadFiles | Multiple lines of text | Just a placeholder department in the form |
| VendorDocAttachments | VendorDocumentsID | Unmarried line of text | Acts as a Strange Cardinal for the items in Vendor Documents library |
Get to Vendor Documents library and customize the form using PowerApps
In the left card, Tree View option will be selected (if not selected, click and get to the view). Under the Screens, expand the SharePointForm1 which displays the Title column.
In social club to add the newly added column, after expanding the SharePointForm1 on the right side Edit Form property screen will appear. Click on the Edit fieldsàAdd fieldàUploadFiles (search for it) àAdd
Once the field is added, plough the DataCardValue2 visibility to off.
At present we need an attachment controller which is by default not bachelor in the SharePoint libraries.
And so, open whatever list parallelly in a new tab and click customize the form using PowerApps. Under the Tree View -> Screens, expand the SharepointForm1 and copy the attachments control lone (here the name is DataCardValue3)
Go back to the Vendor Documents PowerApps form and paste the control under the newly added section
Note: While pasting the control PowerApps will request to confirm whether to unlock the information bill of fare and add the control. Click Unlock and add together
Remove the default values (Parent.Default) to cancel the errors shown past the control
Open the OnAddFile property; articulate the imitation and add together this
ClearCollect(collectionFiles,DataCardValue3.Attachments)
Formula: On the add-on of files, forms collecting and storing the files in a temporary Collections (collectionFiles) in PowerApps from the attachments control field (DataCardValue3)
OnRemoveFile property, add the aforementioned formula to refresh if whatsoever files are removed during preview
Insert a Gallery Control
The information source of the Gallery will exist the collection (collectionFiles) created before
In Gallery Control, remove all the elements except for Title and Image. Resize and make the control (Gallery1) and elements(Title1, Image1) are Invisible (this will human action as a holder for temporary drove). Ensure the control is under the UploadFile DataCard, if the command is created outside of SharePointForm1, cut and paste inside the Datacard.
Where Text to brandish on the elements are:
Title1.Text = ThisItem.Name
Image1.Epitome = ThisItem.Value
Now, insert a button where all the action lies on.
Rename the button to Upload Files and the Text on the push to "Upload Files"
Button action formulas:
In the button OnSelect property create some other drove (collectionFilesGallery) where the "for loop" collects the files and stores as DataStream along with name of the files.
Clear(collectionFilesGallery); { purpose of this line is to clear whatsoever previous values } ForAll(Gallery1.AllItems,Collect(collectionFilesGallery,{Title:Title1.Text,DataStream:Image1.Image})); To exist continued..
Please see: Detailed arroyo on how to bring in an attachment in a SharePoint library (where SP listing will have attachments OOTB but not the library). This article is split into three parts for separating the tasks and this is Role 1
- Link to Function two
- Link to Office three
Source: https://www.c-sharpcorner.com/article/adding-attachments-in-sharepoint-document-library-using-power-apps-list-control/
0 Response to "Upload a File to Sharepoint With Column Names C#"
Post a Comment