0

I've created a SharePoint App which is essentially a list, with some Remote Event Receivers hooked up to certain events. There are no pages in this app, the start page is set to access the list immediately. Also, it's an auto-hosted App.

Now I've created a second App that I would like to access the list data from the first App in. In this second, also auto-hosted App, I've created a Host Web context & tried to access my first App's list as follows:

var list = clientContext.Web.Lists.GetByTitle("App_list_title");

Not surprisingly, it doesn't find the list. I realize there's the divide between the App Web & Host Web & by my understanding the list I've created in App 1 exists inside that app's App Web. Hence it isn't in the Web.Lists collection.

My question is, is there a way to surface the list in App 1 so that it can be accessed from other apps, or is there a different way by which I can access this list data?

Having only just started out with SharePoint, any help would be greatly appreciated.

EDIT

After a few days of putting this aside, I've now come back to it & am still having trouble getting my app to work the way I want. I re-read my question & it might not be clear what I'm trying to achieve.

I want to create an app, which contains a list, to behave like a standard SharePoint list. So my app should be contained in the Web.Lists collection, come up when adding workflows to list events etc. Is something like this possible & if so, how does one go about doing it?

1

When creating a new list in SharePoint 2013 you need to go to "Site Contents" and click the "Add app" button. Technically adding a list is not really an app. Adding a (default) SharePoint list is still based upon templates like is was in previous SharePoint versions. A lot of people find this confusing. I'm not sure why Microsoft did this.

You have 3 options

Create a list template and deploy the list template to the desired site collections. Deploying is just a matter of "Site Settings" -> "Save list as template", download the template and upload it in the new Site Collection.

The 2nd option. Create a sandboxed solution in Visual Studio, create a list template in this solution and deploy it.

The 3rd option is creating an app. Let the app create the list in the Host web (not the app web!). You can do this with remote event handlers or simply with a button on the app page. Some coding is needed here. All the different SharePoint API flavours support adding a list.

Personally I would never create, put or store contents in the app web itself. I also believe that with every update of the app, a new app web is created (and the old one incl. the contents is removed).

  • Ah, that makes more sense now, thank you! Option 2 is out, as I don't believe you can do sandboxed solutions for SharePoint Online. Option 3 looks like the best option, as we'll be using this on a few hundred sites, so having the app sort out the list creation would be handy. Thank you for taking the time to answer. – Carl Heinrich Hancke Jun 12 '14 at 8:31
0

Auto -Hosted apps are going to be deprecated. Reccommended to covert it into Provider hosted or Sharepoint hosted.

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.