{"id":741,"date":"2012-09-24T11:27:16","date_gmt":"2012-09-24T10:27:16","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=741"},"modified":"2012-09-24T11:27:16","modified_gmt":"2012-09-24T10:27:16","slug":"sp2013-sharepoint-hosted-app-getting-to-your-lists","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2012\/09\/sp2013-sharepoint-hosted-app-getting-to-your-lists\/","title":{"rendered":"SP2013: SharePoint hosted app, getting to your lists"},"content":{"rendered":"<p>As described in my previous post, a SharePoint app gets its own Web instance in which it lives. For the SharePoint engine, that means getting rid of your app is easy: just delete the web and everything is gone. The web gives you the option to deploy regular SharePoint stuff like lists and columns. But now that you&#8217;ve got your solution setup with a list; how can you reach it to add items? <!--more--><\/p>\n<p>I&#8217;m not sure yet how Microsoft wants us to work with this model. It&#8217;s not that easy to get to your lists, not for an end user anyway. And since your app uses it&#8217;s own interface, the end-user experience is kind of odd when you switch back and forth between SharePoint UI and your apps&#8217; UI.<\/p>\n<p>What you could do is provide a modal dialog (like the ones in SharePoint, which you can&#8217;t use in your hosted app because you&#8217;re not in SharePoint&#8230;) which loads a form. But you&#8217;ll need the URL of the form, so\u00a0here&#8217;s how\u00a0you get there:<\/p>\n<ul>\n<li>Open your app and copy the URL it presents, it&#8217;ll look something like <strong>https:\/\/localhost:44306\/Pages\/Default.aspx?SPHostUrl=https:\/\/user.sharepoint.com&amp;SPLanguage=en-US&amp;SPAppWebUrl=https:\/\/user-703ae13727445b.sharepoint.com\/TheaterCompany<\/strong><\/li>\n<li>The <strong>SPAppWebUrl<\/strong> query string parameter contains the URL of the web where your sites lives. Run the value through a URL decoder (<a href=\"http:\/\/meyerweb.com\/eric\/tools\/dencoder\/\">http:\/\/meyerweb.com\/eric\/tools\/dencoder\/)<\/a><\/li>\n<li>Find the relative URL of your list (in my case: <strong>Lists\/CharactersInHamlet<\/strong>)<\/li>\n<li>Append that to your web URL so you end up with something like <strong>https:\/\/user-703ae13727445b.sharepoint.com\/TheaterCompany\/Lists\/CharactersInHamlet<\/strong><\/li>\n<\/ul>\n<p>So now that\u00a0you can open up your list, you can click the &#8220;add new item&#8221; link, that&#8217;ll take you to the NewForm.aspx page of your list. And if you want to use that in a modal dialog, thus without all the masterpage stuff around the form, add <strong>&amp;IsDlg=1<\/strong> to the URL to strip the page from all unwanted bits.<\/p>\n<p>That way you can reuse the SharePoint form so you don&#8217;t have to create one yourself. And since SharePoint also does some validation and stuff, that saves more work.<\/p>\n<p>If you want to provide your form in a completely different way, you can just include it in your app as normal ASPX. But then you&#8217;d need to handle validation and postback stuff all yourself. And personally, I would begin to wonder if storing my data in a SQL database wouldn&#8217;t be easier to\u00a0begin with. Especially when you&#8217;re using skilled ASP.NET\u00a0developers\u00a0without SharePoint knowledge to create apps.<\/p>\n<p>The downside to all of this is that you&#8217;re going to end up with a webapp which has little to do with SharePoint. It&#8217;ll be just another ASP.NET web application, linked to from SharePoint. Not much more than you&#8217;d have when you just add a hyperlink to your quick launch bar. Ok, it&#8217;s single sign-on by default, hurray.<\/p>\n<p>For more discussion on this, please visit my forum thread here: <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/appsforsharepoint\/thread\/ec475619-1688-44f8-a26d-ce5ce0cb7984\">http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/appsforsharepoint\/thread\/ec475619-1688-44f8-a26d-ce5ce0cb7984<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As described in my previous post, a SharePoint app gets its own Web instance in which it lives. For the SharePoint engine, that means getting rid of your app is easy: just delete the web and everything is gone. The web gives you the option to deploy regular SharePoint stuff like lists and columns. But<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[75,7,76],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-bX","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/741"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=741"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/741\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}