3

I'm developing a site in .NET 4.5. The site does not use SharePoint, it's standalone. The site does however have a working integration with SharePoint document libraries using the .NET client-side object model (CSOM). I can upload and download documents and I've managed to set metadata on objects when uploading them from the site. So far so good.

The problem is that SharePoint have alot of different document properties/metadata that can be based on document type, be mandatory/not mandatory and be of richer types such as taxonomy properties. The problem is that I cannot, or at least won't try to, mimic all of these properties in my application by leveraging the CSOM API. I would like to lean on SharePoints configuration for these document properties/metadata.

I would like to display the SharePoint Upload File dialog when I upload a file. That way the dialog could include exactly the metadata fields and also flag mandatory fields based on the SharePoint configuration. Here's an example of such a dialog from SharePoint: enter image description here

Is it possible for me to display this dialog from my system? Preferably using an iframe but I'm open to all different solutions.

I'm currently targeting SharePoint 2013 and 2016 but if necessary I would be willing to set this feature exclusively to SharePoint 2016.

Any help or pointers to examples/documentation would be greatly appreciated.

2

The SharePoint's upload dialog of a particular library can be accessed from

http://site/_layouts/Upload.aspx?List={ID to the library}

You can get the ID by e.g. going to the Document Library Settings, and the URL should end with List=<ID>. Note, that if the URL starts with %7B and ends with %7D, those are decoded to { and } respectively, meaning you don't have to add the braces to the URL.

By having the desired properties of files to be uploaded associated with the library, your upload form shows the input fields as in your picture.

IFrame is one option. Taking an IFrame from a SP site brings the whole page layout, so you might want to have a custom page layout for your upload form to exclude everything unnecessary from the frame.

A completely alternative option could be to have a kind of handmade upload form, which scraps the inputs and uploads the file with passed properties using SP's REST API. I would imagine this is more used approach, but that's just a hunch. More about the how the upload works here.

  • Thanks! I'll look into this. I'll mark it as accepted if I succeed. – mikeesouth Jun 22 '17 at 8:36
  • I'm getting CORS troubles, do you know how I would allow or circumvent this problem? Normally we use the .NET API (CSOM) that does not run into CORS but since this is on the client side using Javascript we need to handle CORS. Maybe it's a separate question... – mikeesouth Jun 26 '17 at 8:27
  • @mikeesouth it's indeed likely worth of another question - some further details would be needed to pinpoint to the solution. There exists some broad explanations of how CORS actions should be accesses in e.g. here and some insight about this solution should be hosted in here. – moe Jun 26 '17 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.