none
Integrating document libraries in March 2014 with SP list as parent entity

    Question

  • This new ability looks fantastic and I would dearly love to use... I'm having an issue though. My primary data element is not a database table but rather a SharePoint list.

    • I have a purchase requisition list in SharePoint with another list for line items.
    • We are using the SP List to allow use of workflows for approval.
    • There doesn't seem to be a way to make the upload work when the parent entity relating to the document library is an SP List.

    Is it a requirement for our Master entity to be a database table? 

    I tried simply adding a browse page for a document library in my app and adding the Upload button. I get "Control can't be used in this context" error. I also tried adding the Parent list in one datasource, the library in another, creating a relationship between, but I get a message "Error accessing the SharePoint site."

    Is there any way to have this work without a database table involved? With our need for workflows the database is simply not relevant/needed. Thanks in advance!!

    Regards,

    Matt

    Monday, March 10, 2014 7:49 PM

All replies

  • Interesting... I have copied the sample almost verbatim from the MSDN video here. Only difference is I have a table called DocumentMaster related to Documents entity which is the SP Library.

    http://channel9.msdn.com/Series/CBA/How-Do-I-Incorporate-Document-Libraries-in-a-Cloud-Business-App-

    Even in this configuration I'm getting an error "Error accessing the SharePoint site". Everything else in the application runs like a top. I can read/write to database and SP lists without issue. When i try to add a new document i get this error.

    Is anyone else having this issue? I'm going to try a from scratch test to see if that has different results. It looks like my issue is separate from using the SP List across 2 datasources and that may work.

    Monday, March 10, 2014 8:40 PM
  • You have to create a related key (string) in your list and the same key name in your document library. Then you have to bind them together in a relation, otherwise you get the error you posted

    Sven Elm

    Monday, March 10, 2014 8:40 PM
  • Sven:

    This relationship has been in place for all of my testing.

    Monday, March 10, 2014 8:44 PM
  • Hi Turn the relation around. You have many to one. It should be one to many

    Sven Elm

    Monday, March 10, 2014 8:54 PM
  • Or is it right. Is testlibrary your document library? Maby its a bug then

    Sven Elm

    Monday, March 10, 2014 8:57 PM
  • Sven,

    Yes, TestLibrary is the document library, DocumentMaster is the DB table. So i have 1 document master database record and many documents to associate.

    I'll try a new test project just to make sure something is not gummed up... fingers crossed!

    Thanks,

    Matt

    Monday, March 10, 2014 9:00 PM
  • Madd,

    I have also set up a parent list with a document library (the document library has a lookup to the master list). I've tried enforcing referential integrity and again with no referential integrity but I am unable to upload documents. 

    Terry McCullagh


    Terry McCullagh www.tothecloud.com

    Monday, March 10, 2014 10:27 PM
  • Terry:

    Are you using SP 2013 On Premise or SharePoint online? I'm using on premise but the video from Beth i believe is SP Online.

    Wondering if that is the difference? Hope I figure this out soon... i may have given my client a timeline based on how simple this looked to be :(

    Thanks,

    Madd

    Monday, March 10, 2014 10:40 PM
  • Hi Madd-

    Based on the error that you're seeing above that says "Error accessing the SharePoint site", it looks like you're hitting a known issue that exists with SharePoint On-Prem if you don't have your on-prem site configured properly.

    I believe that you need to have office server installed on the on-prem machine.  I will get more details for you so that you have the correct steps to configure SharePoint on-prem.

    Thanks,

    Nicole

    Tuesday, March 11, 2014 1:45 PM
  • It appears the upload control requires a relationship defined in lightswitch between the parent entity and the doc library.  Unfortunately, SP lists related using a lookup column in SharePoint is missing a navigation property on the parent side and relationships cannot be created in LS between SP lists...this is a show stopper for the current implementation of the upload control.

    It seems, in a effort to make the control easy and automatic, they've drastically restricted it's usefulness.  I think you can only use the built-in control if:

    You have a DB table related to your document library

    You cannot use the control to simply upload a document to a library without relationship to a table entity.  Nor can you upload to a library related to another SharePoint List.

    Basically what I found is there is no lightswitch navigation property (link) created on the parent side when lists are related using lookup columns in SharePoint.  As a result, the upload control spits 'Control can't be used in this context' error.

    Unless a workaround for this problem can be found, I'd suggest using the upload control found here:

    http://blogs.msdn.com/b/rmattsampson/archive/2013/10/29/html-upload-control-for-lightswitch-sharepoint-apps.aspx

    HTH,

    Josh



    • Edited by joshbooker Tuesday, March 11, 2014 4:50 PM
    Tuesday, March 11, 2014 1:49 PM
  • Madd,

    Using SharePoint Online.

    Terry


    Terry McCullagh www.tothecloud.com

    Tuesday, March 11, 2014 2:02 PM
  • Nicole,

    Wanted to let you know I am experiencing similar problems as Madd using SharePoint Online.


    Terry McCullagh www.tothecloud.com

    Tuesday, March 11, 2014 2:04 PM
  • Madd,

    Is your SharePoint site configured as http or https? If it is http, when you first open the CBA home page in IE, there should be a prompt "Show all contents". Click to enable it, and then proceed to upload your document.

    Let me know if this helps.

    Tuesday, March 11, 2014 5:30 PM
  • Terry,

    Can you tell me exactly what is happening?

    Tuesday, March 11, 2014 5:32 PM
  • Hi Matt,

    Can you tell us the document library configuration?

    - Where does the document library live? Host Web? Another site?

    - Do you have content types enabled in the document library?

    - Do you have custom document templates in the document library?

    Thanks,

    Chaks


    Regards,
    Chakkaradeep | http://twitter.com/chakkaradeep | http://www.chakkaradeep.com

    Tuesday, March 11, 2014 5:53 PM
  • I am getting the same error as Terry. It is caused by a missing Navigation property on the parent side of the relationship.  When you connect to two SP lists which are 'related' using lookup column, you don't get a navigation property on the parent side and the relationship is not editable.  As a workaround,  I modified the entity .lsml for the document library (Documents.lsml in my case)

    You need to remove this text from the .lsml in data sources directory:

            <NavigationProperty.Attributes>
              <Hidden />
            </NavigationProperty.Attributes>

    After that change is made, you can name the Navigation Property on the parent side and it's fixed.

    For example,  I have a SP list called 'Contacts' and a library called 'Documents'.  There is a lookup column in Documents that relates the items to a Contact.  This lookup becomes a relationship in LS and the documents entity has a navigation property to Contact.  However, the Contact entity does not have a navigation property to Documents.  As a result the upload control doesn't work because it checks for association links and if not present it pukes an error and quits.

    To fix this I edited the Documents.lsml and removed the above code and then added a nav property on the Contacts side of the relationship.

    It would be nice if the navigation properties were on both side of the relationship to begin with as this will likely have to be repeated every time you 'Update Datasource'

    UPDATE: In my testing the above change does indeed persist after 'Update Datasource'...sweet!  Also, the only cons that I'm aware of (besides it's said to not be 'supported') are the same limitations that exist with virtual nav properties.  Namely, the nav prop cannot be used in filter or sort.

    So I'd say...what's the harm?

    HTH,

    Josh


    • Edited by joshbooker Friday, March 14, 2014 1:54 AM UPDATE....
    Tuesday, March 11, 2014 5:59 PM
  • Yaqi,

    Using SharePoint Online I have a list named contacts and a document library named documents. There is a lookup from documents to the contacts list.

    I am attempting to incorporate a document library into a cloud business app as presented in http://channel9.msdn.com/Series/CBA/How-Do-I-Incorporate-Document-Libraries-in-a-Cloud-Business-App-

    When running the app I receive an error saying the control can't be used in this context when trying to create or upload a file. 

    Josh described the problem very well. 

    Thanks,

    Terry


    Terry McCullagh www.tothecloud.com

    Wednesday, March 12, 2014 2:16 PM
  • FYI: Michael Simmons said the above edit .lsml workaround is considered 'a currently unsupported scenario'

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/1e7726c5-939d-41d5-8758-1bc960af0ede/related-sharepoint-lists-missing-navigation-properties-bug?forum=lightswitch

    You can use it at your own risk, I know I will.

    The important take away regarding the built-in upload control is the fact that it only works in the context of docs related to entities from a database table (maybe even only intrinsic - I haven't tested).  You cannot even throw the doc list on a browse screen and use the control to upload docs - big fail!

    I'll test the limitations mentioned by Michael and report back in the above linked thread...at some point.

    Josh



    • Edited by joshbooker Wednesday, March 12, 2014 2:40 PM
    Wednesday, March 12, 2014 2:39 PM
  • Hi Josh,

    This initial release of the documents feature supports relating SharePoint document libraries with (non-SharePoint) business entities such as databases, SAP, CRM etc., For databases, it works with both intrinsic and attach scenarios. Please let us know if you have issues relating documents with extrinsic databases.

    Thanks,

    Chaks


    Regards,
    Chakkaradeep | http://twitter.com/chakkaradeep | http://www.chakkaradeep.com

    Friday, March 14, 2014 12:29 AM
  • Thanks for the clarification Chaks.  Glad to see SharePoint blood in LS team (or should I say CBA team?)...I've followed your blog for years.  Here's to many more!  Cheers!

    PS...too bad we cannot even use the built-in control to simply upload documents without a relationship at all - like throw doc list on a screen and upload.   Seems to me it could check for an association link only when it's on a screen in a child context - as opposed to requiring such a context.

    Josh


    • Edited by joshbooker Friday, March 14, 2014 1:38 AM PS...
    Friday, March 14, 2014 1:18 AM
  • Thanks Josh - Glad to hear you follow my blog :)

    We are validating scenarios and it would be very helpful if you are able to send me your application scenario(s) that you have built using LS/CBA + SharePoint or planning to build to chaksc at Microsoft dot com.

    Cheers,

    Chakkaradeep


    Regards,
    Chakkaradeep | http://twitter.com/chakkaradeep | http://www.chakkaradeep.com

    Friday, March 14, 2014 4:26 AM
  • Chakkaradeep:

    To be honest i've tried this in about every scenario possible outside of SP Online and have yet to get the upload working at all. This is with an intrinsic database as well which gives the SharePoint access error shown above in thread.

    With all the time spent/wasted on investigating i had to completely scrap this functionality for now and move on.

    I'll be circling back to in the next week or so to provide more details on the scenario's that have tried. I'm also going to move my work over to the client DEV consolidation server rather than my local DEV VM. Perhaps that may yield results as no scenarios works currently.

    Thanks,

    Matt

    Friday, March 14, 2014 5:45 PM
  • Hi Matt,

    Can you please confirm the following:

    - Where does the document library live? Host Web? Another site?

    - Do you have content types enabled in the document library?

    - Do you have custom document templates in the document library?

    - Do you have custom permissions enabled in the document library?

    - Browser and browser version?

    Thanks,

    Chaks


    Regards,
    Chakkaradeep | http://twitter.com/chakkaradeep | http://www.chakkaradeep.com

    Monday, March 17, 2014 2:08 AM
  • - Where does the document library live? Host Web? Another site?

    • Host Web - all lists are part of the same site at root of new site collection
    • Lists and library are deployed via Visual Studio solution

    - Do you have content types enabled in the document library?

    • Yes, in my advanced application there are custom site columns and content types
    • I have also tried with a OOB custom list and OOB document library though with same issues

    - Do you have custom document templates in the document library?

    • No custom document templates

    - Do you have custom permissions enabled in the document library?

    • No custom permissions

    - Browser and browser version?

    • IE 10

    I will provide more information this week, had to circle of this project but am now back on and will be reviewing.

    Wednesday, March 19, 2014 4:28 PM
  • Hi all,

    It's been awhile but am finally swinging back to this. Have some good news and some bad news.

    Good news, i am able to get this working beautifully on SP Online site. The functionality is fantastic and my users would die to have.

    Bad news, I have not been able to get this to work with On Premise SP 2013. My client is SP 2013 On Premise so online is out in this instance. I get an access denied on the library but am not sure why.

    • I have two Web Apps in play for on premise installation - SP Web Apps and SP APPS HOST

    It's possibly an issue with on-premise and the Apps host IIS application connecting to SharePoint. However, my application can read/write to lists and even Metadata of document library with no issues. Anyone know of authentication differences for this functionality between SP Online and On-Premise?

    Other thought is I don't have Office Web Apps installed on the on-premise. Perhaps this is tied in somehow as new document opens directly on Online Word editing in my working SP Online Demo. Am testing this theory soon and will let everyone know my results.

    Please let me know if anyone has thoughts/ideas.

    Friday, August 8, 2014 9:47 PM