Document Libraries FAQ (Ed Smith)

Document Libraries FAQ (Ed Smith)

  • Comments 4

A recent post, Integrating Documents in Cloud Business Apps, was published on the Apps for Office and SharePoint Blog which discusses the ability to integrate application data with SharePoint document libraries.

In this article, we will review some of the frequently asked questions and their answers. If you have other questions, please leave a comment below and we can add them to the post.

I have some Office document templates I defined for my library. Will they appear in the add/create document popup?

Yes, If there are document templates for your library, they will show up in the add/create popup automatically.

Can I get the path to the document in my server code?

Yes, you can get the items that make up the path off a document entity object. Below is a code snippet that would get the path for a products documents.

foreach (Edtest docEntity in entity.Edtests)


    UriBuilder uriBuilder = newUriBuilder(Application.SharePoint.HostUrl.Scheme, Application.SharePoint.HostUrl.Host, Application.SharePoint.HostUrl.Port, docEntity.Path + "/" + docEntity.Name);

    Uri uri = uriBuilder.Uri;

    //Do something with the uri


What happens if I connect to a document library that is not on the app’s host web?

The document library needs to reside on the same site and host web as the app to properly authenticate to the SharePoint site. If they do not reside on the same site, there will be a runtime error message like the one below when you try to access the documents tab.

An error occurred while processing this request. Inner exception message:{“error”:”invalid_client”,”error_description”:”Invalid audience Uri ‘00000003-0000-03d1-ce00-000000000000\/’.”}

If you publish and specify a production SharePoint site, we will automatically update the data source SharePoint site address to point at the new site. So you need to make sure you have the library defined with your necessary columns on that site as well.

On my on-premises SharePoint, my app’s upload popup only shows upload, but not the new document options?

When apps are installed in on-premises installations on SharePoint, the new document options will not appear in the upload popup. The SharePoint capability that allowed this was rolled out cloud first to SharePoint online and is not available in on-premises SharePoint yet.

How does CBA know when to open the document in Office desktop clients and not in the browser?

When creating new documents, we will always create the document in Office Online. When opening existing documents, we will open them in Office desktop if it is installed, and in Office Online if it is not installed.

Which relationship parents are supported for the document library feature?

This initial release of the document library feature supports relating Office 365 or SharePoint document libraries with (non-SharePoint) business entities such as databases, SAP, CRM, etc. For databases, it works with both intrinsic and attach scenarios. In this release we do not support having SharePoint list as the parent entity to a document library.


I hope you found this FAQ useful. If you have further questions, the LightSwitch forums are a great place to get answers.


-Ed Smith, Software Development Engineer in Test, Cloud Business Applications Team

Leave a Comment
  • Please add 7 and 2 and type the answer here:
  • Post
  • Q: Can I use upload control with a doc library related to a sharepoint entity?

    A: No, upload control needlessly requires a relationship to a non-sharepoint entity otherwise you get invalid context error.

    Q: Can I simply throw doc list on a browse screen and use upload control?

    A: No, Same answer as above.

    More info:

  • Thanks Josh for your feedback, I clarified our parent entity support in the post.  Please continue to leave comments here or in the forums if you have suggestions or questions.

  • I have a question about the answer to the question: "What happens if I connect to a document library that is not on the app’s host web?"

    Since the Cloud Business App template includes a very minimal SharePoint App project and manifest, is it not possible to add a library to the SharePoint app project, so that the library is provisioned on the app web (not the host web), so that you can then connect to the library which was provisioned by the solution itself?

    Now, I haven't tested this myself yet, but I hope the answer is yes. If not, there's a whole world of functionality that seems to be absent by not leveraging the ability to provision SharePoint artifacts onto the app web using the new SharePoint app model. I understand that there would be challenges on the LightSwitch side because, since the solution includes the SharePoint project, if the project hasn't been deployed previously, the design-time wizards in LightSwitch would not be able to find the library via a SharePoint url. Perhaps there is a way to inspect the SharePoint app project itself, identify the features being provisioned, and provide the user with the option to connect to a library or list at design-time, repointing the URL to the app web at deploy or runtime, similar to how the SharePoint app project uses tokens to achieve the same effect.

  • Michael,

    You comment is spot on.   Please see the same question asked and answered in comments here:

    While this is old info, I don't believe the story has changed.  You can provision lists to the app web from your LS SharePoint project, but you cannot use them as data source at design time.

    We likely won't see this ability until\unless LS allows changing connection strings at runtime.  You can vote for the highly-popular, long-standing suggestion here:

Page 1 of 1 (4 items)