<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Visual Studio LightSwitch Team Blog</title><link>http://blogs.msdn.com/b/lightswitch/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>OData Apps in Update 2 - Querying Data from Stack Overflow</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/23/odata-apps-in-update-2-querying-data-from-stack-overflow.aspx</link><pubDate>Thu, 23 May 2013 13:53:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10420904</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10420904</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/23/odata-apps-in-update-2-querying-data-from-stack-overflow.aspx#comments</comments><description>&lt;p&gt;Matt Sampson's got a &lt;a href="http://blogs.msdn.com/b/rmattsampson/archive/2013/05/23/odata-apps-in-update-2.aspx"&gt;blog&lt;/a&gt; about making a&amp;nbsp;LightSwitch HTML App that queries data from the one and only &lt;a href="http://stackoverflow.com"&gt;Stack Overflow&lt;/a&gt;&amp;nbsp;by attaching to their&amp;nbsp;very cool&amp;nbsp;public OData Service.&lt;/p&gt;
&lt;p&gt;(Now you can use a LightSwitch app to keep track of all the LightSwitch related posts on Stack Overflow!)&lt;/p&gt;
&lt;p&gt;You can check out the blog post here - &lt;a href="http://blogs.msdn.com/b/rmattsampson/archive/2013/05/23/odata-apps-in-update-2.aspx"&gt;OData Apps in Update 2&amp;ndash;Querying data from Stack Overflow&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I published the HTML App up into azure if you'd like a preview of it - &lt;a href="http://lightswitchrms.azurewebsites.net/HTMLClient"&gt;StackOverflow App&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks all - Matt Sampson&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10420904" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Matt+Sampson/">Matt Sampson</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/OData/">OData</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/JavaScript/">JavaScript</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML+Client/">HTML Client</category></item><item><title>Creating a wizard-like experience for HTML client (Andy Kung)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/16/creating-a-wizard-like-experience-for-html-client-andy-kung.aspx</link><pubDate>Thu, 16 May 2013 15:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10418660</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10418660</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/16/creating-a-wizard-like-experience-for-html-client-andy-kung.aspx#comments</comments><description>&lt;p&gt;If you have been playing with the new HTML client, you will know that LightSwitch provides a built-in screen template for creating data. It allows user to input data via a modal dialog. In some scenarios, however, we’d much prefer to guide the user via a step-by-step wizard-like dialog. &lt;/p&gt;  &lt;p&gt;In this article, I will show you how to create such experience by customizing the built-in screen template. We will create a simple survey app that that allows users to enter data via a 3-step “wizard.” Something like this: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7206.clip_5F00_image002_5F00_023C345D.jpg"&gt;&lt;img title="clip_image002" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5153.clip_5F00_image002_5F00_thumb_5F00_73FDBB6C.jpg" width="900" height="400" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let’s Begin!&lt;/p&gt;  &lt;h2&gt;Set up the database&lt;/h2&gt;  &lt;p&gt;Create a &lt;b&gt;LightSwitch HTML Application&lt;/b&gt; (VB or C#). Name it &lt;b&gt;MySurvey&lt;/b&gt;. On the start screen, click &lt;b&gt;Create new table&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3000.clip_5F00_image004_5F00_53E2AEAF.jpg"&gt;&lt;img title="clip_image004" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1856.clip_5F00_image004_5F00_thumb_5F00_76A6771D.jpg" width="573" height="234" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Name the table &lt;b&gt;Survey&lt;/b&gt; and add 3 String fields: &lt;b&gt;Name&lt;/b&gt;, &lt;b&gt;Quest&lt;/b&gt;, and &lt;b&gt;Color&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0451.clip_5F00_image006_5F00_289E17A8.jpg"&gt;&lt;img title="clip_image006" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image006" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3583.clip_5F00_image006_5F00_thumb_5F00_1D748D5E.jpg" width="900" height="234" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Create a survey list&lt;/h2&gt;  &lt;p&gt;In &lt;b&gt;Solution Explorer&lt;/b&gt;, right click on &lt;b&gt;HTMLClient&lt;/b&gt; node to add a screen. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7725.clip_5F00_image008_5F00_4F6C2DE8.jpg"&gt;&lt;img title="clip_image008" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image008" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6330.clip_5F00_image008_5F00_thumb_5F00_2F51212B.jpg" width="434" height="346" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We’d like to create a screen with a list of surveys. In &lt;b&gt;Add New Screen&lt;/b&gt; dialog, select &lt;b&gt;Browse Data Screen&lt;/b&gt; template, name the screen &lt;b&gt;SurveyList&lt;/b&gt;, and pick &lt;b&gt;Surveys&lt;/b&gt; as &lt;b&gt;Screen Data&lt;/b&gt;. Click &lt;b&gt;OK&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4276.clip_5F00_image010_5F00_242796E1.jpg"&gt;&lt;img title="clip_image010" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image010" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2133.clip_5F00_image010_5F00_thumb_5F00_040C8A24.jpg" width="900" height="639" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Create a “New Survey” dialog&lt;/h2&gt;  &lt;p&gt;We’d like to create an add button for the survey list. In &lt;b&gt;Survey List&lt;/b&gt; screen, right click on &lt;b&gt;Command Bar&lt;/b&gt; node to add a button. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5265.clip_5F00_image012_5F00_36042AAE.jpg"&gt;&lt;img title="clip_image012" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image012" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8311.clip_5F00_image012_5F00_thumb_5F00_2ADAA064.jpg" width="447" height="210" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;In the &lt;b&gt;Add Button&lt;/b&gt; dialog, pick &lt;b&gt;Surveys.addAndEditNew&lt;/b&gt; and leave &lt;b&gt;Navigate To&lt;/b&gt; as &lt;b&gt;New Screen&lt;/b&gt;. This tells the system that this button will &lt;i&gt;add a new item&lt;/i&gt; to the &lt;i&gt;survey list&lt;/i&gt; via a &lt;i&gt;new screen&lt;/i&gt; we’re about to create. Click &lt;b&gt;OK&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3443.clip_5F00_image014_5F00_11729D2A.jpg"&gt;&lt;img title="clip_image014" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image014" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1300.clip_5F00_image014_5F00_thumb_5F00_7157906C.jpg" width="634" height="285" /&gt;&lt;/a&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;LightSwitch will guide us to create an &lt;b&gt;Add/Edit Details Screen&lt;/b&gt;. Name the new screen &lt;b&gt;NewSurvey&lt;/b&gt;. Click OK. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7245.clip_5F00_image016_5F00_662E0622.jpg"&gt;&lt;img title="clip_image016" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image016" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7750.clip_5F00_image016_5F00_thumb_5F00_4612F965.jpg" width="900" height="641" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Define steps for the wizard&lt;/h2&gt;  &lt;p&gt;In the &lt;b&gt;New Survey&lt;/b&gt; screen, you will notice we have one tab group under the &lt;b&gt;Tabs&lt;/b&gt; node. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4606.clip_5F00_image018_5F00_25F7ECA8.jpg"&gt;&lt;img title="clip_image018" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image018" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0486.clip_5F00_image018_5F00_thumb_5F00_57EF8D32.jpg" width="333" height="288" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We want to simulate a 3-step wizard by using 3 tabs, showing one tab (step) at a time. &lt;/p&gt;  &lt;p&gt;Add 2 new tab groups by right clicking on &lt;b&gt;Tabs&lt;/b&gt; node. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7343.clip_5F00_image020_5F00_1ED8B030.jpg"&gt;&lt;img title="clip_image020" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image020" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2475.clip_5F00_image020_5F00_thumb_5F00_7EBDA372.jpg" width="709" height="440" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the first tab group. In &lt;b&gt;Properties&lt;/b&gt;, change &lt;b&gt;Name&lt;/b&gt; to &lt;b&gt;Step1&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5618.clip_5F00_image022_5F00_73941928.jpg"&gt;&lt;img title="clip_image022" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image022" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4213.clip_5F00_image022_5F00_thumb_5F00_258BB9B3.jpg" width="444" height="230" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Name the same property to &lt;b&gt;Step2&lt;/b&gt; and &lt;b&gt;Step3&lt;/b&gt; for the other 2 tab groups. &lt;/p&gt;  &lt;p&gt;Since we only want to show one question for each step, move &lt;b&gt;Name&lt;/b&gt; directly under the first tab group. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8345.clip_5F00_image024_5F00_1A622F69.jpg"&gt;&lt;img title="clip_image024" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image024" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7840.clip_5F00_image024_5F00_thumb_5F00_4C59CFF3.jpg" width="333" height="438" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Move &lt;b&gt;Quest&lt;/b&gt; and &lt;b&gt;Color&lt;/b&gt; to &lt;b&gt;Step2&lt;/b&gt; and &lt;b&gt;Step3&lt;/b&gt; tab groups respectively. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2072.clip_5F00_image026_5F00_413045A9.jpg"&gt;&lt;img title="clip_image026" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image026" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3652.clip_5F00_image026_5F00_thumb_5F00_211538EC.jpg" width="331" height="411" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Since we have no use of the columns node under the first tab group, delete it. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4048.clip_5F00_image028_5F00_00FA2C2F.jpg"&gt;&lt;img title="clip_image028" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image028" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7271.clip_5F00_image028_5F00_thumb_5F00_47E34F2C.jpg" width="319" height="333" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hit &lt;b&gt;F5&lt;/b&gt; key to run the application. Click the &lt;b&gt;Add Survey&lt;/b&gt; button. You will see we have an add dialog to add a new survey. There are 3 tab groups, each containing a survey question. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2313.clip_5F00_image030_5F00_3CB9C4E2.jpg"&gt;&lt;img title="clip_image030" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image030" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0250.clip_5F00_image030_5F00_thumb_5F00_6EB1656C.jpg" width="590" height="890" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Customize the dialog into a “wizard”&lt;/h2&gt;  &lt;p&gt;To make this more like a step-by-step wizard, we need to do a couple of tweaks. First, we only want to show the &lt;b&gt;Save&lt;/b&gt; button in the last step. Second, we want to hide the tab titles to prevent the user from jumping directly to a step. &lt;/p&gt;  &lt;p&gt;Close the browser and go back to &lt;b&gt;Visual Studio&lt;/b&gt;. Let’s make these changes. &lt;/p&gt;  &lt;p&gt;In &lt;b&gt;New Survey&lt;/b&gt; screen, select the screen root node. Go to &lt;b&gt;Properties&lt;/b&gt; window and check &lt;b&gt;Hide Tab Titles&lt;/b&gt;. This will hide the title of each tab group. Also select &lt;b&gt;Browse&lt;/b&gt; for &lt;b&gt;Screen Type&lt;/b&gt;. This will display a &lt;b&gt;Close&lt;/b&gt; button instead of a &lt;b&gt;Save&lt;/b&gt; button in the modal dialog. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8764.clip_5F00_image032_5F00_4E9658AF.jpg"&gt;&lt;img title="clip_image032" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image032" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8371.clip_5F00_image032_5F00_thumb_5F00_30B7D4AE.jpg" width="826" height="495" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you run the application now, you will only see the first tab showing. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6237.clip_5F00_image034_5F00_109CC7F1.jpg"&gt;&lt;img title="clip_image034" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image034" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3404.clip_5F00_image034_5F00_thumb_5F00_1E6F0DEC.jpg" width="581" height="889" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;All we need to do now is to place a &lt;b&gt;Next&lt;/b&gt; button to go to the next step. &lt;/p&gt;  &lt;h2&gt;Create navigation buttons&lt;/h2&gt;  &lt;p&gt;Right click on &lt;b&gt;Command Bar&lt;/b&gt; node under the first tab to add a button. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7536.clip_5F00_image036_5F00_7E54012E.jpg"&gt;&lt;img title="clip_image036" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image036" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6131.clip_5F00_image036_5F00_thumb_5F00_732A76E4.jpg" width="464" height="339" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In &lt;b&gt;Add Button&lt;/b&gt; dialog, select &lt;b&gt;Write my own method&lt;/b&gt; and name it &lt;b&gt;ShowStep2&lt;/b&gt;. Click &lt;b&gt;OK&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2330.clip_5F00_image038_5F00_2522176F.jpg"&gt;&lt;img title="clip_image038" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image038" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3010.clip_5F00_image038_5F00_thumb_5F00_32F45D6A.jpg" width="621" height="273" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Double click on the new button will take you to the code editor. We will use the &lt;b&gt;showTab&lt;/b&gt; API to display the next tab group (step). We will also update the dialog title programmatically as we move from step to step. &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.ShowStep2_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Write code here.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; line-height: 10pt"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Go back to the &lt;b&gt;New Survey&lt;/b&gt; screen. Follow the same steps to create a &lt;b&gt;ShowStep3&lt;/b&gt; button for the 2&lt;sup&gt;nd&lt;/sup&gt; tab (step). &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.ShowStep3_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Write code here.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step3&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 3&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;On the last tab (step), we want a &lt;b&gt;Save&lt;/b&gt; button. Add a button to the 3&lt;sup&gt;rd&lt;/sup&gt; tab (step) and name the method &lt;b&gt;Finish&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7635.clip_5F00_image040_5F00_2BD520F2.jpg"&gt;&lt;img title="clip_image040" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image040" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3438.clip_5F00_image040_5F00_thumb_5F00_0743936E.jpg" width="620" height="270" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Write the following code. The &lt;b&gt;commitChanges&lt;/b&gt; API will save the screen and close the dialog. &lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.Finish_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Write code here.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.commitChanges();&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Run the application and add a survey by following the “wizard. “ &lt;/p&gt;  &lt;h2&gt;Handle validation errors&lt;/h2&gt;  &lt;p&gt;One problem you might notice is that we don’t prevent you from going into the next step even if there are validation errors. We want to surface these error messages before letting the user continue. &lt;/p&gt;  &lt;p&gt;Update the 3 code methods as the following:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.ShowStep2_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// If no value is entered, manually set the field to null to trigger 'required' validation&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; (screen.Survey.Name == &lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.Survey.Name = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Go to next step only if there are no validation errors associated with the field. &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; contentItem = screen.findContentItem(&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Name&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (contentItem.validationResults.length === 0) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.ShowStep3_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// If no value is entered, manually set the field to null to trigger 'required' validation&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; (screen.Survey.Quest == &lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.Survey.Quest = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Go to next step only if there are no validation errors associated with the field. &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; contentItem = screen.findContentItem(&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Quest&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (contentItem.validationResults.length === 0) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step3&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 3&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.Finish_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// If no value is entered, manually set the field to null to trigger 'required' validation&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; (screen.Survey.Color == &lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.Survey.Color = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Save changes only if there are no validation errors associated with the field. &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; contentItem = screen.findContentItem(&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Color&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (contentItem.validationResults.length === 0) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.commitChanges();&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;There are 2 new things we’re doing here:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In HTML client, we don’t show the &lt;b&gt;required field&lt;/b&gt; error message until the value is change by the user. Because of this reason, we are programmatically setting the value back to null. This will trigger the error message to show if the user just click &lt;b&gt;Next&lt;/b&gt; button without entering anything. &lt;/li&gt;    &lt;li&gt;We only allow you to move to the next step if there are no errors at the current step. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Run the application and click &lt;b&gt;Next&lt;/b&gt; without any value. We now prevent you from going into the next step prematurely. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0880.clip_5F00_image042_5F00_672886B0.jpg"&gt;&lt;img title="clip_image042" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image042" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6746.clip_5F00_image042_5F00_thumb_5F00_3BE3EFA9.jpg" width="521" height="709" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Polish the experience&lt;/h2&gt;  &lt;p&gt;There are a couple of enhancements we can do:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Change the &lt;b&gt;Display Name&lt;/b&gt; of the questions to make it more descriptive (ex. What… is your name?). You can do so via &lt;b&gt;Properties&lt;/b&gt;. &lt;/li&gt;    &lt;li&gt;Change the &lt;b&gt;Display Name&lt;/b&gt; and &lt;b&gt;Icon&lt;/b&gt; of the buttons via &lt;b&gt;Properties&lt;/b&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0207.clip_5F00_image044_5F00_6DDB9033.jpg"&gt;&lt;img title="clip_image044" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image044" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4431.clip_5F00_image044_5F00_thumb_5F00_4DC08376.jpg" width="518" height="709" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Bonus: Add some Back buttons&lt;/h2&gt;  &lt;p&gt;You can add some Back buttons to the flow by utilizing the same &lt;b&gt;showTab&lt;/b&gt; API. For example, in &lt;strong&gt;Step 2&lt;/strong&gt;, you can include a &lt;strong&gt;Back&lt;/strong&gt; button with the following method:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.BackStep1_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Go back to step 1&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step1&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2376.clip_5F00_image046_5F00_4296F92C.jpg"&gt;&lt;img title="clip_image046" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image046" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1200.clip_5F00_image046_5F00_thumb_5F00_227BEC6F.jpg" width="519" height="710" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Bonus: Add an optional step&lt;/h2&gt;  &lt;p&gt;Sometimes the next set of questions is based on a question user answers at the current step. In case you did not get the joke in my example, the 3 questions are taken from the movie &lt;b&gt;Monty Python and the Holy Grail&lt;/b&gt;. Let’s add an additional step to ask if people get the joke. &lt;/p&gt;  &lt;p&gt;Add a &lt;b&gt;Boolean&lt;/b&gt; field &lt;b&gt;GetTheJoke&lt;/b&gt; in the &lt;b&gt;Survey&lt;/b&gt; table. Uncheck the &lt;b&gt;Required&lt;/b&gt; box to make it an optional field. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2870.clip_5F00_image048_5F00_494A02AF.jpg"&gt;&lt;img title="clip_image048" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image048" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2783.clip_5F00_image048_5F00_thumb_5F00_571C48AA.jpg" width="900" height="234" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In &lt;b&gt;New Survey&lt;/b&gt; screen, add another tab group (step) and name it &lt;b&gt;OptionalStep&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1715.clip_5F00_image050_5F00_4FFD0C32.jpg"&gt;&lt;img title="clip_image050" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image050" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2476.clip_5F00_image050_5F00_thumb_5F00_48DDCFBA.jpg" width="360" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Drag &lt;b&gt;GetTheJoke&lt;/b&gt; field from the data members list under the tab group. Change the &lt;b&gt;Display Name&lt;/b&gt; of the field. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2308.clip_5F00_image052_5F00_56B015B5.jpg"&gt;&lt;img title="clip_image052" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image052" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0825.clip_5F00_image052_5F00_thumb_5F00_7D7E2BF5.jpg" width="685" height="573" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Add a &lt;b&gt;Next&lt;/b&gt; button in the group by creating a new method. It simply goes to &lt;b&gt;Step 2&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2235.clip_5F00_image054_5F00_2DA8076A.jpg"&gt;&lt;img title="clip_image054" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image054" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1731.clip_5F00_image054_5F00_thumb_5F00_5F9FA7F4.jpg" width="314" height="129" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.OptionalStep_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Write code here.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;In the original &lt;b&gt;ShowStep2&lt;/b&gt; method, let’s add an &lt;b&gt;IF&lt;/b&gt; statement before showing Step 2. If the user’s name does not contain “Sir”, let’s ask if they get the joke.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;myapp.NewSurvey.ShowStep2_execute = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (screen) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// If no value is entered, manually set the field to null to trigger 'required' validation&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; (screen.Survey.Name == &lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.Survey.Name = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt" color="#008000"&gt;// Go to next step only if there are no validation errors associated with the field. &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt; contentItem = screen.findContentItem(&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Name&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; (contentItem.validationResults.length === 0) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt; (screen.Survey.Name.indexOf(&lt;/span&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font color="#a31515"&gt;&amp;quot;Sir&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font style="font-size: 9.5pt"&gt;) &amp;lt; 0) {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font color="#a31515"&gt;&amp;quot;OptionalStep&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: yellow"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;} &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#0000ff"&gt;else&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt; {&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.showTab(&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;screen.details.displayName = &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font color="#a31515"&gt;&amp;quot;Step 2&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font style="font-size: 9.5pt"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; line-height: normal; text-autospace: ; mso-layout-grid-align: none"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font style="font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.5pt"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in; line-height: 12pt"&gt;&lt;span style="font-family: ; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; color: ; line-height: 10pt; mso-highlight: white"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.5pt"&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: ; color: ; line-height: 10pt"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Run the application and try out the optional step.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2728.clip_5F00_image056_5F00_066DBE35.jpg"&gt;&lt;img title="clip_image056" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image056" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1346.clip_5F00_image056_5F00_thumb_5F00_6652B177.jpg" width="901" height="368" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h1&gt;Conclusion&lt;/h1&gt;  &lt;p&gt;We have successfully created a step-by-step wizard-like experience by customizing the built-in screen template! We learned how to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create multiple steps by adding multiple screen tabs &lt;/li&gt;    &lt;li&gt;Make the dialog looks like a wizard by hiding screen titles and the save button &lt;/li&gt;    &lt;li&gt;Navigate to the next step and update title &lt;/li&gt;    &lt;li&gt;Save and close the wizard programmatically &lt;/li&gt;    &lt;li&gt;Handle validation errors at each step &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;As King Arthur would say, “You have to know these things when you’re a king, you know.”&lt;/p&gt;  &lt;p&gt;-andy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10418660" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/How_2D00_To/">How-To</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Andy+Kung/">Andy Kung</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Screen+Design/">Screen Design</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/JavaScript/">JavaScript</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML+Client/">HTML Client</category></item><item><title>Customizing the SharePoint Chrome Control in LightSwitch</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/14/customizing-the-sharepoint-chrome-control-in-lightswitch.aspx</link><pubDate>Tue, 14 May 2013 15:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10414908</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10414908</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/14/customizing-the-sharepoint-chrome-control-in-lightswitch.aspx#comments</comments><description>&lt;p&gt;If you’ve done any LightSwitch apps for SharePoint you may have noticed that we incorporate a version of the SharePoint chrome control.&amp;#160; You may not have known what it was (or what it was called), but you do now.&amp;#160; You can also customize it and I’ll show you how.&amp;#160; I’m also going to cover a few things like navigating to the home page or retrieving the current user, things that apply to non-SharePoint apps as well.&lt;/p&gt;  &lt;p&gt;The chrome control is just a little frame at the top of your app that by default let’s you jump quickly back to the SharePoint site that launched the app.&amp;#160; Here’s the quick &amp;amp; easy app we created in a &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/03/07/a-quick-amp-easy-lightswitch-app-for-sharepoint.aspx"&gt;previous post&lt;/a&gt; called “CustEdit” – you can see the chrome control was put in for us automatically.&amp;#160; It also matches the color theme of the SharePoint site the app was launched from – that may or may not be what you want but we’ll cover that in another post.&amp;#160; For now we just want to add a little more than what the default provides.&amp;#160; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3857.image_5F00_63E9E0A6.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7658.image_5F00_thumb_5F00_2A66D0AF.png" width="385" height="535" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We’ll add:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A Home button that will take the user to the home page of the app&lt;/li&gt;    &lt;li&gt;A button that will take the user back to the SharePoint site&lt;/li&gt;    &lt;li&gt;The current user’s name and a link to the “my site”&lt;/li&gt;    &lt;li&gt;A “Sign Out” link&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s get started.&lt;/p&gt;  &lt;h3&gt;Add createSharePointChrome Function&lt;/h3&gt;  &lt;p&gt;LightSwitch will create the chrome for you but if it finds a declared JavaScript function called createSharePointChrome() then LightSwitch will use that to render the chrome control instead.&amp;#160; The frame of the control will remain the same but you can change the contents to whatever you want.&amp;#160; So the first thing we need to do is create this function and make it part of our project. Taking our CustEdit example, perform the following steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In Solution Explorer, switch to &lt;strong&gt;File View&lt;/strong&gt; and then &lt;strong&gt;Show all Files&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Expand the &lt;strong&gt;CustEdit.HTMLClient&lt;/strong&gt; node, right-click on the &lt;strong&gt;UserCode &lt;/strong&gt;node and select &lt;strong&gt;Add&amp;gt;New item…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Add a new javascript file and name it &lt;strong&gt;customchrome.js&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Open up the &lt;strong&gt;default.htm&lt;/strong&gt; file in the code editor and add a reference to the script file:&lt;/li&gt; &lt;/ul&gt;  &lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: maroon;"&gt;script &lt;/span&gt;&lt;span style="background: white; color: red;"&gt;type&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;=&amp;quot;text/javascript&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: red;"&gt;src&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;=&amp;quot;UserCode/customchrome.js&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: maroon;"&gt;script&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;blockquote&gt;Open up the customechrome.js file and declare the function: &lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;createSharePointChrome(element, spUrl) {

    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//create the links we need for the chrome on O365
&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
&lt;/span&gt;&lt;/pre&gt;
  &lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;Press F5 and run your app – you should see an empty chrome.&amp;#160; That means LightSwitch found your empty function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, we need some code to render the buttons.&amp;#160; The image I want to use for the SharePoint site, I’ll just pull from SharePoint itself.&amp;#160; For the home button I want to use the SharePoint app icon that’s part of the SharePoint project.&amp;#160; To add that, I’ll just create a link to that png file from the SharePoint project to the Server project.&amp;#160; Also, I customized my SharePoint appicon, but you don’t have to do that for this work, the default will work just fine.&amp;#160; The key here is that the SharePoint project will want an icon that is 96x96.&amp;#160; So if you don’t want to create one, just use the default.&lt;/p&gt;

&lt;p&gt;To use a new icon:&amp;#160; (skip past this stuff to the next set of bullets if you want to use the default icon)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Still in File View, right-click the &lt;strong&gt;CustEdit.SharePoint&lt;/strong&gt; project node and select &lt;strong&gt;Add &amp;gt; Existing item…&lt;/strong&gt;&lt;/li&gt;

  &lt;li&gt;Browse to your 96x96 png file and add it to your project&lt;/li&gt;

  &lt;li&gt;Open the &lt;strong&gt;appmanifest.xml&lt;/strong&gt; file in the SharePoint project&lt;/li&gt;

  &lt;li&gt;In the &lt;strong&gt;Icon&lt;/strong&gt; text box browse to the png file you added&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2352.image_5F00_65BA366D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5670.image_5F00_thumb_5F00_039B4B20.png" width="781" height="399" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now create the link to the file in the server project:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right-Click on the &lt;strong&gt;CustEdit.Server&lt;/strong&gt; project and select &lt;strong&gt;Add &amp;gt;Existing Item…&lt;/strong&gt;&lt;/li&gt;

  &lt;li&gt;Browse to the &lt;strong&gt;CustEdit.SharePoint&lt;/strong&gt; project on disk, and select the icon you want to use (mine is &lt;strong&gt;custedit.png&lt;/strong&gt; the default is &lt;strong&gt;AppIcon.png&lt;/strong&gt;)&lt;/li&gt;

  &lt;li&gt;Click the arrow next to the &lt;strong&gt;Add&lt;/strong&gt; button in the File Open dialog and select &lt;strong&gt;Add as link&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5001.image_5F00_69C714F0.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7658.image_5F00_thumb_5F00_37634171.png" width="326" height="224" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll now see a reference to the png file in the server project.&amp;#160; If you ever change that file in the SharePoint project, it will be automatically updated in the Server Project.&amp;#160; If you change the icon to another file, you’ll need to repeat those steps. So now you have this:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0207.image_5F00_529B9A72.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2845.image_5F00_thumb_5F00_2E0A0CEE.png" width="324" height="345" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Next let’s add code to the createSharePointChrome() function:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: green;"&gt;//add the links
&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A class='msls-sharepoint-chrome-link ui-link home-link' href='#'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
      &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;img style='margin-left: 4px; margin-right: 4px;' height='24' width='24'&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
           &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;src='../custedit.png'&amp;lt;/A&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
   &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A class='msls-sharepoint-chrome-link ui-link' href='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ spUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
       &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;img &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;style='margin-left: 4px; margin-right: 4px; padding: 4px;'&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
             &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;src='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ spUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/_layouts/15/images/favicon.ico'&amp;lt;/A&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;).appendTo(element);

&lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//use the built-in LightSwitch method for the home page 
&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;.home-link&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, element).click(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;() {
    msls.application.navigateHome();
});
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Press F5 to run the app and you’ll see the two image links in the chrome.&amp;#160; If you used the default appicon, then of course yours will be different.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6175.image_5F00_494265EF.png"&gt;&lt;font color="#424242"&gt;&lt;/font&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6562.image_5F00_thumb_5F00_24B0D86B.png" width="277" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Getting the User Name on the Server in the HTML Client&lt;/h3&gt;

&lt;p&gt;Now we want to add the current user name to the chrome.&amp;#160; We’ll also throw in the “Sign Out” link.&amp;#160; Note that this isn’t specific to SharePoint apps, any HTMLClient may want to use this technique.&amp;#160; We’ll use AJAX to call into the LightSwitchApplication on the server which has easy access to this information.&lt;/p&gt;

&lt;p&gt;The first thing we need to do is add a generic http handler to our server.&amp;#160; Right-click on the &lt;strong&gt;CustEdit.Server&lt;/strong&gt; project node in &lt;strong&gt;Solution Explorer&lt;/strong&gt;.&amp;#160; Select &lt;strong&gt;Add&amp;gt;New item…&lt;/strong&gt; – scroll down to find the &lt;strong&gt;Generic Handler&lt;/strong&gt; and name it &lt;strong&gt;GetAppInfo.ashx&lt;/strong&gt;.&amp;#160; In the code editor add the following snippet in the ProcessRequest sub.&lt;/p&gt;

&lt;p&gt;VB:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Sub &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;ProcessRequest(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;ByVal &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Implements &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IHttpHandler&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.ProcessRequest

    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;serverContext = LightSwitchApplication.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateContext()
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;spContext = serverContext.Application.SharePoint.GetHostWebClientContext()
            spContext.Load(spContext.Web)
            spContext.ExecuteQuery()

            context.Response.ContentType = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;text/plain&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context.Response.Write(spContext.Web.Title)
            context.Response.Write(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)
            context.Response.Write(serverContext.Application.User.FullName)
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;End Using
    End Using
   
End Sub&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;C#:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;public void &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;ProcessRequest(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;HttpContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context)
{
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;serverContext = &lt;br /&gt;           LightSwitchApplication.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateContext())
    {
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(Microsoft.SharePoint.Client.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ClientContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;spContext = &lt;br /&gt;               serverContext.Application.SharePoint.GetHostWebClientContext())
        {
            spContext.Load(spContext.Web);
            spContext.ExecuteQuery();

            context.Response.ContentType = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;text/plain&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
            context.Response.Write(spContext.Web.Title);
            context.Response.Write(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;);
            context.Response.Write(serverContext.Application.User.FullName);
        }
    }            
}
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;This response will give us the user’s name and the “friendly” name of the SharePoint site that launched the app.&amp;#160; We could use the name of the site for a link or some alt text (as in this example), regardless it shows you a way to use the SharePoint CSOM from the client.&amp;#160; Now that we have the handler in place, we need some AJAX to call the handler.&amp;#160; This will still be part of our createSharePointChrome() function.&amp;#160; Let’s just replace what we have now with the entire snippet below.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;createSharePointChrome(element, spUrl) {

    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//create the links we need for the chrome on O365
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;mySite = spUrl.replace(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;.sharepoint&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;-my.sharepoint&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;i = mySite.indexOf(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;.com&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) + 4;
    mySite = mySite.substring(0, i) + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/person.aspx&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;signoutUrl = spUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/_layouts/15/signout.aspx&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;UserName;

    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//call the code on the server
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$.ajax({
        type: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'GET'&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        data: {},
        url: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'../GetAppInfo.ashx'&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        success: &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;success(response) {
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;n = response.split(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;);
            myHostWebName = n[0];
            UserName = n[1];

            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//add the links
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A class='msls-sharepoint-chrome-link ui-link home-link' href='#'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                  &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;img style='margin-left: 4px; margin-right: 4px;' height='24' width='24'&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                       &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;src='../custedit.png'&amp;lt;/A&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
            &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A class='msls-sharepoint-chrome-link ui-link' href='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ spUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                  &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;img alt='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ myHostWebName + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;' &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                       &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;style='margin-left: 4px; margin-right: 4px; padding: 4px;'&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                       &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;src='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ spUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/_layouts/15/images/favicon.ico'&amp;lt;/A&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;).appendTo(element);

            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//use the built-in LightSwitch method for the home page 
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;.home-link&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, element).click(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;() {
                msls.application.navigateHome();
            });

            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//right side links
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;$(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;DIV style='float:right;padding-right:12px'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A id='myname' &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ 
                   &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;style='padding-top:2px' class='msls-sharepoint-chrome-link ui-link' &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                   &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;target='_blank' href='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ mySite + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ UserName + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;/A&amp;gt; | &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                 &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;A class='msls-sharepoint-chrome-link ui-link' href='&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ signoutUrl + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;'&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+
                     &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Sign Out&amp;lt;/A&amp;gt;&amp;lt;/DIV&amp;gt;&amp;quot;
                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;).appendTo(element);
        }
    });
}&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;And now your chrome should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3426.image_5F00_3216EB71.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3326.image_5F00_thumb_5F00_0D855DED.png" width="350" height="610" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it!&amp;#160; Now you know:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;what the chrome is&lt;/li&gt;

  &lt;li&gt;how to customize the chrome with some images&lt;/li&gt;

  &lt;li&gt;how to change the SharePoint app icon&lt;/li&gt;

  &lt;li&gt;how to use the Home Page function the LightSwitch HTML client library&lt;/li&gt;

  &lt;li&gt;how to use AJAX to call into the LightSwitch application and SharePoint CSOM on the server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helps, your comments are always welcome.&lt;/p&gt;

&lt;p&gt;Brian Moore - Program Manager, LightSwitch&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10414908" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/SharePoint/">SharePoint</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Brian+Moore/">Brian Moore</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML+Client/">HTML Client</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Chrome/">Chrome</category></item><item><title>Announcing Runtime Update 1 - Supporting jQueryMobile 1.3</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/07/announcing-runtime-update-1-supporting-jquerymobile-1-3.aspx</link><pubDate>Tue, 07 May 2013 16:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10415751</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10415751</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/07/announcing-runtime-update-1-supporting-jquerymobile-1-3.aspx#comments</comments><description>&lt;p&gt;When we took a bet on jQuery, jQueryMobile, and datajs for our HTML client, we recognized that we’d need to adapt to the rapid release cadence these frameworks employ.&amp;#160; At the same time, we know that small issues in our application runtime can cause considerable strife.&amp;#160; Our response is to start delivering a series of small, servicing releases for our HTML client runtime via NuGet that address known bugs and compatibility issues with emerging versions of jQuery, jQueryMobile, and datajs.&amp;#160; Today we’ve released the first update onto the NuGet gallery—Microsoft.LightSwitch.Client.JavaScript.Runtime update 1!&lt;/p&gt;  &lt;p&gt;This first update adds support for jQueryMobile 1.3 and jQuery 1.9. Especially jQueryMobile 1.3 brings a lot of improvements and bug fixes. Embracing the mobile-first, instead of mobile-only, approach was the main focus of this release. This was achieved by implementing a popular technique called responsive design. New widgets like &lt;a href="http://view.jquerymobile.com/1.3.1/dist/demos/widgets/table-column-toggle/"&gt;tables&lt;/a&gt; and &lt;a href="http://view.jquerymobile.com/1.3.1/dist/demos/widgets/panels/"&gt;panels&lt;/a&gt; work efficiently on large screens as well as small phones, enabling data-richer scenarios. Also jQueryMobile and jQueryUI are working closer together with the goal of having even more shared code and conventions.&lt;/p&gt;  &lt;p&gt;&lt;img title="jQueryMobiles new responsive table widget" alt="jQueryMobiles new responsive table widget" src="http://jquerymobile.com/wp-content/uploads/2013/01/jqm-tables_reflow.png" width="640" height="330" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;&lt;span style="font-size: xx-small;"&gt;(picture taken from the jQueryMobile 1.3 announcement)&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;While we cannot add new design time features as part of a runtime update, you can still start using these new controls today by utilizing the power of our custom controls. A combination of our blog posts around custom controls and &lt;a href="http://view.jquerymobile.com/1.3.1/dist/demos/"&gt;jQueryMobile’s excellent documentation&lt;/a&gt; will help you to get started. Michael dedicated a complete post to the integration of &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2012/12/19/enhancing-lightswitch-controls-with-jquery-mobile-michael-zlatkovsky.aspx"&gt;jQueryMobile controls as custom controls&lt;/a&gt; and our post about &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/01/14/visualizing-list-data-using-a-map-control-heinrich-wendel.aspx"&gt;using a maps control to visualize list data&lt;/a&gt; explains the API of the LS collection which you need to implement your own table control.&lt;/p&gt;  &lt;h2&gt;How to update?&lt;/h2&gt;  &lt;p&gt;Thanks to NuGet the installation of a runtime update is a simple, two-step process. First, you update the “Microsoft.LightSwitch.Client.JavaScript.Runtime” package, which will automatically pull in the latest supported versions of our dependencies. Second, you bump the version numbers of the updated JavaScript and CSS files in the &lt;em&gt;default.htm&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Due to a known bug with NuGet, JavaScript projects and source control you need to unbind your solution from source control before updating the NuGet packages. Open File –&amp;gt; Source Control –&amp;gt; Advanced –&amp;gt; Change Source Control and unbind your solution and the projects it contains. After performing the following steps bind it again and merge in the new changes. &lt;/p&gt;  &lt;p&gt;Start by switching to the file view of the solution explorer. The context menu of the HTML client project contains the entry “Manage NuGet Packages…”. Selecting the “Updates” section of the package manager will show the following screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5482.nuget_2D00_update_5F00_12F7B81E.png"&gt;&lt;img title="nuget-update" style="display: inline; background-image: none;" border="0" alt="nuget-update" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2843.nuget_2D00_update_5F00_thumb_5F00_6093E49E.png" width="644" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Updating the LightSwitch runtime will automatically update jQuery and jQueryMobile for you. After a quick restart of Visual Studio and reopening the project you need to make a few changes in the &lt;em&gt;default.htm&lt;/em&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;light-theme.css&lt;/em&gt; to light-theme-&lt;strong&gt;1.0.1&lt;/strong&gt;.css&lt;/li&gt;    &lt;li&gt;&lt;em&gt;mlsls-light.css&lt;/em&gt; to msls-light-&lt;strong&gt;1.0.1&lt;/strong&gt;.css&lt;/li&gt;    &lt;li&gt;&lt;em&gt;jquery.mobile.structure-1.2.0.min.css&lt;/em&gt; to jquery.mobile.structure-&lt;strong&gt;1.3.0&lt;/strong&gt;.min.css&lt;/li&gt;    &lt;li&gt;&lt;em&gt;msls-1.0.0.min.css&lt;/em&gt; to msls-&lt;strong&gt;1.0.1&lt;/strong&gt;.min.css&lt;/li&gt;    &lt;li&gt;&lt;em&gt;jquery-1.8.2.min.js&lt;/em&gt; to jquery-&lt;strong&gt;1.9.1&lt;/strong&gt;.min.js&lt;/li&gt;    &lt;li&gt;&lt;em&gt;jquery.mobile-1.2.0.min.js&lt;/em&gt; to jquery.mobile-&lt;strong&gt;1.3.0&lt;/strong&gt;.min.js&lt;/li&gt;    &lt;li&gt;&lt;em&gt;msls-1.0.0.min.js&lt;/em&gt; to msls-&lt;strong&gt;1.0.1&lt;/strong&gt;.min.js&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;F5 and you are done. Since NuGet packages are defined on a per project basis, you need to perform those steps for every project you have. Also keep in mind that jQuery and jQueryMobile remove functionality that was previously deprecated with every release. If you are heavily customizing your LightSwitch application using JavaScript code this might affect you. Make sure to carefully study their release notes in order to learn about new features and removed functionality:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://jquerymobile.com/blog/2013/02/20/jquery-mobile-1-3-0-released/" target="_blank"&gt;jQuery Mobile 1.3.0 Released&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/" target="_blank"&gt;jQuery 1.9 final, jQuery 2.0 beta, Migrate final released&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you have any problems with the upgrade or want to learn more about using some of the new features you can find us in the &lt;a href="http://social.msdn.microsoft.com/Forums/en-us/lightswitch/threads"&gt;forums&lt;/a&gt; or the comments section below.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;- Heinrich Wendel, Program Manager LightSwitch Team&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10415751" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Announcement/">Announcement</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML/">HTML</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/jQueryMobile/">jQueryMobile</category></item><item><title>ASP.NET SignalR and LightSwitch (Matt Sampson)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/03/asp-net-signalr-and-lightswitch-matt-sampson.aspx</link><pubDate>Fri, 03 May 2013 13:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10415887</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10415887</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/03/asp-net-signalr-and-lightswitch-matt-sampson.aspx#comments</comments><description>&lt;p&gt;Maybe you've already heard about &lt;a href="http://www.asp.net/signalr"&gt;ASP.NET SignalR&lt;/a&gt;&amp;nbsp;and how you can use it to do "real-time" web.&lt;/p&gt;
&lt;p&gt;Or how it lets you easily push content from your server up into your HTML5 Client, or back from your client to the server.&lt;/p&gt;
&lt;p&gt;But have you seen how you can make SignalR and LightSwitch work together???&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to know more, then check out this blog post from Matt Sampson - &lt;a href="http://blogs.msdn.com/b/rmattsampson/archive/2013/03/14/asp-net-signalr-in-lightswitch.aspx"&gt;ASP.NET SignalR and LightSwitch&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks all,&lt;/p&gt;
&lt;p&gt;-Matt Sampson&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10415887" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Matt+Sampson/">Matt Sampson</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/SignalR/">SignalR</category></item><item><title>Localizing a LightSwitch Application (Heinrich Wendel)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/05/02/localizing-a-lightswitch-application.aspx</link><pubDate>Thu, 02 May 2013 17:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10413208</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10413208</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/05/02/localizing-a-lightswitch-application.aspx#comments</comments><description>&lt;p&gt;With Visual Studio Update 2 we finally added a functionality a lot of you (especially outside the US) have been waiting for, the localization of LightSwitch applications into multiple languages. Until then you had to hardcode a single language into your application. Finally, international companies and companies that are located in countries that use multiple official languages, can provide users with an application in their preferred language.&lt;/p&gt;
&lt;p&gt;The concept is simple. For each &lt;em&gt;DisplayName&lt;/em&gt; or &lt;em&gt;Description&lt;/em&gt; property that you want to localize, you specify a &lt;em&gt;$(ResourceString)&lt;/em&gt; instead of the actual string. For each translation, you create a resource file which contains the actual values in the target language. At runtime, we will automatically detect the preferred language based on the user&amp;rsquo;s browser or operating system setting. In addition to that, strings that you specify on the server, e.g. names for entities or properties, are also propagated to the client, no need to translate them twice. And, you can also localize messages that are created while running business logic on the server or validation rules on the client.&lt;/p&gt;
&lt;p&gt;We already published a &lt;a href="http://msdn.microsoft.com/en-us/library/vstudio/xx130603.aspx"&gt;walkthrough on MSDN&lt;/a&gt; which gives you a detailed step by step description. But, there is only one language that everybody in the world understands. It is the language of pictures. I tried to create a visual walkthrough for you guys. Click the picture bellow to start your localization experience (it might take a while to load, there are quite a few pictures in it).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://heiwen.azurewebsites.net/loc" target="_blank"&gt;&lt;img style="display: inline; background-image: none;" title="loc" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1680.loc_5F00_3D27970F.png" alt="loc" width="646" height="365" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For some reason it doesn&amp;rsquo;t work as expected, your see strings like &amp;ldquo;/client/ErrorMessage&amp;rdquo; or &amp;ldquo;$(ContactPhone)&amp;rdquo; in the UI? As so often, the devil lies in the details. In the last part of this blog post I&amp;rsquo;ll try to summarize the questions and problems that came up most often in our &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/lightswitch/threads" target="_blank"&gt;forums&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What are valid keys for resource identifiers? &lt;/strong&gt;You should only use letters and numbers for resource identifiers. Don&amp;rsquo;t use spaces and to be absolutely safe stay away from any special characters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the naming convention for Server resource files?&lt;/strong&gt; The server project uses &amp;ldquo;Service.resx&amp;rdquo; (Service, not Server &lt;img class="wlEmoticon wlEmoticon-smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8371.wlEmoticon_2D00_smile_5F00_5561356A.png" alt="Smile" /&gt;) for the neutral translations and &amp;ldquo;Service.LocaleID.resx&amp;rdquo; for individual languages. Those files live in the root folder of the server project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the naming convention for Silverlight resource files?&lt;/strong&gt; The Silverlight client uses &amp;ldquo;Client.resx&amp;rdquo; for the neutral translations and &amp;ldquo;Client.LocaleID.resx&amp;rdquo; for individual languages. Those files live in the root folder of your Silverlight client project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the naming convention for HTML resource files?&lt;/strong&gt; For the HTML client use &amp;ldquo;client.lang-LocaleID.resjson&amp;rdquo; for all languages. Simply use the appropriate locale id for the neutral language. Those files live in the &amp;ldquo;Content/Resources&amp;rdquo; folder of your HTML client project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Where do I specify the neutral language&lt;/strong&gt;? You can specify the neutral language in your project properties. It defaults to your Visual Studio language when creating a new project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why are the naming conventions for HTML and Silverlight/Server different?&lt;/strong&gt; We tried to follow the conventions of the technologies the individual projects are based on. For the Server and Silverlight we use the .NET conventions and resx files, for HTML we are following the WinJS naming conventions using resjson files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How does the language detection mechanism work? &lt;/strong&gt;If you run a Silverlight application we will use the user&amp;rsquo;s Windows language as preferred language. If you run an HTML app we will use the browser setting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Can I present users with a choice of languages? &lt;/strong&gt;Not at the moment, sorry. Usually it is pretty easy to change the language of your browser though and you can also change the language of Windows on a per user basis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How does the server know about the client&amp;rsquo;s language? &lt;/strong&gt;With every HTTP request your browser sends the client language as part of the ACCEPT_LANGUAGES header. ASP.NET will run the thread that is processing the request using the culture specified by the header.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;My client shows the raw resource strings, what is wrong? &lt;/strong&gt;Did you translate both your client and server into the specific language? We will only pick up a language if both projects actually provide translations, otherwise users could end up with a mix of languages in their UI.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;That&amp;rsquo;s it&lt;/h2&gt;
&lt;p&gt;I tried to keep it a bit shorter this time. As always, use the comments section and our &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/lightswitch/threads" target="_blank"&gt;forums&lt;/a&gt; for feedback and questions.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;- Heinrich Wendel, Program Manager LightSwitch&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10413208" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Validation/">Validation</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Heinrich+Wendel/">Heinrich Wendel</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Localization/">Localization</category></item><item><title>Publishing LightSwitch apps for SharePoint to the Catalog (Brian Moore)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/04/29/publishing-lightswitch-apps-for-sharepoint-to-the-catalog.aspx</link><pubDate>Mon, 29 Apr 2013 15:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10413814</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10413814</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/04/29/publishing-lightswitch-apps-for-sharepoint-to-the-catalog.aspx#comments</comments><description>&lt;p&gt;Ok, your app is done, you’ve learned how to authenticate it and publish it &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/04/02/sharepoint-hosting-options-for-lightswitch.aspx" target="_blank"&gt;like I demonstrated in my previous post&lt;/a&gt;.&amp;#160; When you’re done with the publish wizard on a SharePoint app, you’ll see an explorer window open with folders for each version of your app.&amp;#160; Probably just 1.0.0.0 so far - in the folder is a .app package.&amp;#160; This .app package will always contain the information SharePoint needs to install and run your app.&amp;#160; Things like permissions, end points, project artifacts (like lists), etc.&amp;#160; This .app package is what you give to SharePoint to make your app available to users.&lt;/p&gt;  &lt;p&gt;If you published an autohosted app, then the package also contains the LightSwitch application itself.&amp;#160; All the files that make up your web site.&amp;#160; If you published a provider-hosted app, then all of those files that make up your web site are already on a live server somewhere (if you did a remote publish) or in a WebDeploy package waiting for you to deploy the package.&amp;#160; In the provider-hosted case, you do want to make sure that your LightSwitch app is running before any users install the app package into SharePoint otherwise they’ll just see a 404 of some sort.&lt;/p&gt;  &lt;p&gt;So now what do you do with this .app package?&lt;/p&gt;  &lt;h3&gt;Apps for SharePoint&lt;/h3&gt;  &lt;p&gt;First, a little background on the app model for SharePoint.&amp;#160; Everything on SharePoint 2013 is an app.&amp;#160; All the things you might be familiar with (list, libraries, code) are packaged into an app for SharePoint.&amp;#160; This way, whenever the user wants something for the site, there’s an app for that.&amp;#160; Where do you get apps?&amp;#160; From the store.&amp;#160; For Office365 there is a public store that contains public apps.&amp;#160; Some are free, some have other licensing models.&amp;#160; You can also get apps from a private app catalog for your SharePoint site.&amp;#160; So basically you have access to public apps and private apps.&amp;#160; LightSwitch can build apps for either scenario, though there are some things to be aware of which I’ll cover later.&lt;/p&gt;  &lt;p&gt;So when you publish a LightSwitch app for SharePoint, you will publish not only your web application but also the app package that will be uploaded to the App Catalog or SharePoint store.&amp;#160; So let’s take a look at this from end to beginning.&lt;/p&gt;  &lt;h3&gt;The App Catalog&lt;/h3&gt;  &lt;p&gt;Even though you can put your LightSwitch app in both the app catalog or the SharePoint Store, I’m going to walk through the App Catalog scenario.&amp;#160; Your LOB apps written in LightSwitch (especially your first one) are likely to be “private” apps so first things first.&amp;#160; When you want to add an app to your site, you can go to the site contents and, well, add an app.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8321.image_5F00_236F92A3.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0878.image_5F00_thumb_5F00_39C537E8.png" width="706" height="522" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When you click add, you’ll see all the apps that come with SharePoint, all the lists and libraries you might be familiar with.&amp;#160; When you put your LightSwitch app in the app catalog, it will show up here as well.&amp;#160; Since there are a lot of apps already for your site, you can look for apps just from your catalog by clicking the “From Your Organization” link.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7823.image_5F00_05276C5E.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7888.image_5F00_thumb_5F00_69193E23.png" width="694" height="611" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Yours will probably look like this (empty).&amp;#160; Also notice the link to the “public” store.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1680.image_5F00_0D412964.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0028.image_5F00_thumb_5F00_35DF956B.png" width="708" height="462" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So we need to get our app into our catalog – and if this is the first time you’re working with the catalog, you might not even have a catalog yet.&amp;#160; A private app catalog for apps “From Your Organization” is another SharePoint site collection in your tenant.&amp;#160; It’s a special site template that any site in your tenant can attach to, to install apps.&amp;#160; So to create one we need to go to Site Admin to create an app catalog.&amp;#160; First step is to go to SharePoint central admin.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4130.image_5F00_5E7E0172.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7457.image_5F00_thumb_5F00_32CD3776.png" width="648" height="318" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then go to “apps” and select “App Catalog”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7853.image_5F00_42DC062D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0511.image_5F00_thumb_5F00_7E2F6BEB.png" width="647" height="438" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You’ll see an option to create a new catalog or use an existing one, if you don’t have one, just create a new one – you can change anything you need to later.&amp;#160; It will take SharePoint a few minutes to provision the new site and the page won’t necessarily refresh on it’s own (in case you’re waiting for that spinning circle to go away to know when it’s done).&lt;/p&gt;  &lt;p&gt;Now that you have the catalog you need to get the app in the catalog.&amp;#160; Remember this catalog is just another site for SharePoint so you can navigate to it and that’s how you’ll add apps.&amp;#160; You can see your app catalog listed in your site collections in the admin center.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7853.image_5F00_1967C4ED.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5381.image_5F00_thumb_5F00_1FAE9B7B.png" width="688" height="440" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Navigate to that URL and you are at your app catalog.&amp;#160; Remember that URL because there isn’t really any other way to get to it other than what I just showed you (at least not that *I* know of).&amp;#160; Drill down to the “Apps for SharePoint” section and you’ll see any apps you have that can be installed onto a SharePoint site.&amp;#160; Since I just created this catalog I don’t have any apps.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2555.image_5F00_16C199ED.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6355.image_5F00_thumb_5F00_5D3E89F5.png" width="695" height="295" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Putting Your App in the Catalog&lt;/h3&gt;  &lt;p&gt;We’re almost there… now we just need to take the .app package we built and put it into the catalog.&amp;#160; Just click the “new app” link and you’ll be prompted for the package.&amp;#160; When the app is uploaded you will be prompted to fill in the metadata for the app catalog.&amp;#160; There is a lot there, but it’s all optional except the name.&amp;#160; You can provide a description, change the icon, add images to show case the app.&amp;#160; You can even make it a “noteworthy” app that will pop it to the top of the list when users browse the catalog.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4300.image_5F00_467F426C.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4606.image_5F00_thumb_5F00_7400622F.png" width="712" height="302" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once you’ve saved the app, you’ll see it in the list.&amp;#160; Remember that this is our “private” catalog that contains apps just “From Your Organization” but your users will need permission to the app catalog site to see it.&amp;#160; First, here’s what you should see in the catalog.&amp;#160; Over time you’ll see more apps here and also versions of each app that you can manage throughout your organization.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5873.image_5F00_1A62457B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8883.image_5F00_thumb_5F00_27C85881.png" width="708" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To grant permission to the catalog you assign permissions to the catalog site just like you do any other SharePoint site collection – through the Site Settings for that site.&amp;#160; This will let you determine which users on your site can *see* apps from this catalog.&amp;#160; To install apps on a particular site, the user must have permission to install apps on that particular site.&amp;#160; So seeing something in the catalog is necessary but not sufficient for installing it.&amp;#160; And as you might guess, you may not want all users to install apps and by default they won’t be able to until you grant them permission.&amp;#160; So, first they need permission to the catalog site to even see the apps.&amp;#160; Then they need permissions on an individual site, to be able to install the app.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3288.image_5F00_631BBE3F.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3617.image_5F00_thumb_5F00_7E541740.png" width="701" height="309" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And finally, just to add another layer on here – just because an app is installed on a site, doesn’t mean all users can run the app.&amp;#160; You may not want everyone to access an app that’s installed and you can again, control that by setting the appropriate permissions in SharePoint.&amp;#160; That’s enough about permissions for now – suffice it to say, that just like any other LOB LightSwitch app, you can still control who accesses your application when it’s running on SharePoint, using what will become (if it’s not already) the familiar SharePoint permission model.&lt;/p&gt;  &lt;p&gt;After all that, in this example we’re just going to keep using our own user account which owns the site collection for the app catalog and the dev site, but you can drill in here whenever you’re ready ;)&lt;/p&gt;  &lt;h3&gt;Installing Your App from the Catalog&lt;/h3&gt;  &lt;p&gt;Once you have the app in the catalog, there is one path your users will go through to install the app, or any app for that matter.&amp;#160; Again, the user must have permission to install apps onto the site.&amp;#160; Note, that when using a dev site, there are a few ways to install apps onto the site, but for now, let’s walk through what end users will see on non-developer sites.&amp;#160; I used a project site template for this example, but it will look similar to most templates when it comes to installing apps.&amp;#160; First, go to the site contents:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1122.image_5F00_4779C2FA.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6332.image_5F00_thumb_5F00_6DDBA645.png" width="727" height="540" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;From there you will have the option to “add an app”.&amp;#160; Once you click to add the app you’ll see a list of the apps available to the site.&amp;#160; Here you can find your app in the list of all the apps - you see our CustEdit app below.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4846.image_5F00_16E64542.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1541.image_5F00_thumb_5F00_0026FDB9.png" width="728" height="550" /&gt;&lt;/a&gt;&amp;#160; &lt;p&gt;You can also filter the list to show only the apps in your catalog by choosing “From Your Organization” as we did at the beginning of the blog.&amp;#160; Note, that this is the same catalog I was using above, this catalog is shared among all the sites in my tenant – it is “for my organization”.&amp;#160; So everyone in my company or tenant can see this app if I give them permission.&amp;#160; So you can configure permissions for installing or browsing apps in just about any configuration you can imagine.&amp;#160; For example, even though your organization can share a single catalog, you can still restrict who can see particular apps in that catalog.&amp;#160; And also restrict who can install apps on a given site.&amp;#160; The flexibility that is there though is a bit beyond the scope of what I want to cover here (though it feels like I just covered it so I might as well summarize).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Users need to be granted permission to the app catalog site to be able to see apps “From your Organizaition.”&amp;#160; You just navigate to the catalog site, then the site settings and set perms like you do for any other SharePoint site&lt;/li&gt;    &lt;li&gt;Users need permission to install apps on a particular SharePoint site (for example Site Owners can install apps, Site Members cannot)&lt;/li&gt;    &lt;li&gt;You can restrict who can see an app in the catalog by setting permissions for a particular app.&amp;#160; By default anyone who you gave access to in the first bullet above will be able to see the app (perms are inherited) but you can change that&lt;/li&gt;    &lt;li&gt;Once an app is installed on a site, you can further restrict who can run that app via permissions on the installed app&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;But for now, since you likely own everything you’re working with, you really don’t need to set any perms yet.&lt;/p&gt;  &lt;p&gt;So that’s the app store experience.&amp;#160; Once you install an app from the catalog it will show up under your Site Contents just like every other app installed on that site.&lt;/p&gt;  &lt;h3&gt;Installing Apps on a Dev Site&lt;/h3&gt;  &lt;p&gt;You might be wondering by now why you never had to do any of this while you were developing your app.&amp;#160; Developer sites in SharePoint give you some extra functionality to make life as a SharePoint developer easier :) and that’s why.&amp;#160; But that only works on dev sites, to get apps onto non-dev sites, you need to go through the catalog.&lt;/p&gt;  &lt;p&gt;There is, as you might have guessed another way to install an app onto a dev site without going through the catalog.&amp;#160; When you F5 your app from VS, the app package is technically installed on the SharePoint dev site and pointing to your application on localhost.&amp;#160; VS does all of that for you.&amp;#160; If you want to actually run your app from the cloud (in this case) instead of localhost, you can do that on a dev site without putting it into the catalog.&amp;#160; You do that by going to the dev site’s “apps in testing” section and selecting “new app to deploy”.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6813.image_5F00_1B5F56BA.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2781.image_5F00_thumb_5F00_23E2B604.png" width="731" height="555" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There’s one thing to be aware of going down this path particularly if you’ve been developing your app against this same site.&amp;#160; Remember that I said VS installs the app for you while you’re debugging?&amp;#160; That means your app is probably still installed on this site and if you try to install it again, SharePoint will tell you it’s already installed.&amp;#160; VS doesn’t uninstall it every time you stop debugging because, well, it would take longer to install it again the next time you started debugging, we might as well leave it there -- you probably debug much more often than you do this catalog stuff.&amp;#160; Anyway, if you do get that error, just click in the ellipses by your app and remove it, then try the deploy again. &lt;/p&gt;  &lt;p&gt;Finally, another option you have (and you may very well want test this out some day) is upgrading an app that’s already installed.&amp;#160; This is what would happen if you release a new version into the app catalog and users had installed your app.&amp;#160; They would get notification that a new version is available and SharePoint would upgrade your app.&amp;#160; This would include upgrading your autohosted database if you had one.&amp;#160; To try that out, go up to the ribbon and select “Upgrade an app”.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5482.image_5F00_1A898181.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1373.image_5F00_thumb_5F00_71154040.png" width="711" height="587" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;The SharePoint Store&lt;/h3&gt;  &lt;p&gt;You probably want me to wrap this up by now, but I do want to make a quick mention of the SharePoint Store or the public catalog.&amp;#160; The process for getting your apps into the Office 365 SharePoint Store is, as you might well imagine, very different.&amp;#160; I’m not going to cover that yet.&amp;#160; A few notable things if you want to try this yourself before I get to it.&amp;#160; You will need to make some changes to the manifest to get the store to “accept” your app.&amp;#160; The error will be descriptive but if you need help leave a comment or &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/lightswitch/threads" target="_blank"&gt;post in the forum&lt;/a&gt; and we can try to cover it briefly.&amp;#160; Also, the SharePoint Store does not *yet* accept autohosted SharePoint apps.&amp;#160; That means you’d have to host the LightSwitch application yourself and deal with multi-tenancy in your LightSwitch app, not to mention pay for hosting it.&amp;#160; So we have a few things we need to make much easier before I cover that in a post.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Finally…&lt;/h3&gt;  &lt;p&gt;That’s all for now, but before I go I want to mention one last thing – partially because I seem to get more comments on a blog when I mention Ms. Massi somehow.&amp;#160; Beth got engaged a few weeks back and for someone who has done as much for our community as she has, we all certainly wish her the best.&amp;#160; Congrats!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;- Brian Moore, Program Manager, LightSwitch&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10413814" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Deployment/">Deployment</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/SharePoint/">SharePoint</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Brian+Moore/">Brian Moore</category></item><item><title>Dashboard Reports with LightSwitch, WebAPI and ServerApplicationContext– Part Deux (Steve Lasker)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/04/25/create-dashboard-reports-with-lightswitch-and-webapi-part-deux.aspx</link><pubDate>Thu, 25 Apr 2013 15:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10413542</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10413542</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/04/25/create-dashboard-reports-with-lightswitch-and-webapi-part-deux.aspx#comments</comments><description>&lt;h2&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;With a little homage to &lt;a href="http://en.wikipedia.org/wiki/Hot_Shots!_Part_Deux" target="_blank"&gt;Hot Shots Part Deux&lt;/a&gt; we’ll drill in a bit deeper utilizing the ServerApplicationContext for creating Dashboard reports. Part 1 is here: &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/04/22/create-dashboard-reports-with-lightswitch-webapi-and-serverapplicationcontext.aspx"&gt;&lt;em&gt;Create Dashboard Reports with LightSwitch, WebAPI and ServerApplicationContext &lt;/em&gt;&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;u&gt;LightSwitch Productivity/Extendability disclaimer&lt;/u&gt;&lt;/strong&gt;: As with Part 1, this isn’t the normal point &amp;amp; click RAD productivity you’ve likely become used to with LightSwitch. This is more of an advanced scenario, showing the extension points we’ve enabled to extend the out of the box features. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In Part 2 I’ll cover:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Adding a second set of charts that enable drilling into monthly data to see a weekly slice of data based on the click events of the chart&lt;/li&gt;    &lt;li&gt;Adding date controls to select the date range of the report&lt;/li&gt;    &lt;li&gt;Interactively making selections in the screen, changing the data displayed&lt;/li&gt;    &lt;li&gt;Calling Stored Procedures from WebAPI&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s get started…&lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Create the AmazingPie Restaurant Point of Sale (POS) database&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;As with part one, we’ll utilize the &lt;a href="http://code.msdn.microsoft.com/Lightswitch-AmazingPie-6b4665c6" target="_blank"&gt;AmazingPie POS Sample database&lt;/a&gt;. However, this code also assumes you’ve already completed &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/04/22/create-dashboard-reports-with-lightswitch-webapi-and-serverapplicationcontext.aspx" target="_blank"&gt;Part 1&lt;/a&gt;. &lt;/p&gt;  &lt;h2&gt;&lt;b&gt;Adding the new Report&lt;/b&gt;&lt;/h2&gt;  &lt;p&gt;We’ll start by adding a WebAPI, allowing us to query based on a time period of Monthly or Weekly. &lt;/p&gt;  &lt;p&gt;1. As in Part 1, we’ll need to switch from the &lt;u&gt;logical view &lt;/u&gt;to &lt;u&gt;file view &lt;/u&gt;so we can interact directly with files.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7674.SolutionExplorerToggleFileView_5F00_7B034E3A.png" /&gt;&lt;/p&gt;  &lt;p&gt;2. Within the Reports folder, add the new Web API controller&lt;/p&gt;  &lt;p&gt;If you’ve followed the previous step, Visual Studio will remember the last few template types you’ve added, and you’ll see a shortcut in your menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1207.image_5F00_24E26015.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0624.image_5F00_thumb_5F00_16A3E725.png" width="554" height="214" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This will provide an abbreviated prompt. Name our controller &lt;b&gt;SeatedGuestsController&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0647.image_5F00_045B2063.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6813.image_5F00_thumb_5F00_122D665E.png" width="303" height="91" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3. Remove all the template Get, Put, Post, Delete methods to make way for our new Report methods.&lt;/p&gt;  &lt;p&gt;4. Add the Extension Methods for query operators&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: this is an important step. Without these extension methods, the LINQ query operators will not be available on the DataWorkspace, and SqlFunctions will require the full namespace&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;hr /&gt;VB
&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Option Infer On
&lt;font color="#a5a5a5"&gt;Imports &lt;/font&gt;&lt;/span&gt;&lt;font color="#a5a5a5"&gt;&lt;span&gt;System.Net
&lt;/span&gt;&lt;span&gt;Imports &lt;/span&gt;&lt;span&gt;System.Web.Http&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Microsoft.LightSwitch
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;LightSwitchApplication
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Configuration
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data.SqlClient
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;System.Data.Objects.SqlClient&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;C#
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span   "=""&gt;using System;
&lt;span&gt;using System.Collections.Generic;
&lt;/span&gt;&lt;span&gt;using System.Linq;
&lt;/span&gt;&lt;span&gt;using System.Net;
&lt;/span&gt;&lt;span&gt;using System.Net.Http;
&lt;/span&gt;&lt;span&gt;using System.Web.Http;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Microsoft.LightSwitch;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Configuration;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data.SqlClient;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;System.Data.Objects.SqlClient;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;font color="#000000"&gt;5. Add the following Method to expose our WebAPI Method&lt;/font&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font color="#000000"&gt;The get will capture the period, and we’ll call sub methods for each specific report&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;&lt;font face="Segoe UI" size="2"&gt;&lt;strong&gt;VB
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;Public Class &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SeatedGuestsController
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Inherits &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;ApiController
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetValue(period &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;br /&gt;                             beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime, endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime)
&lt;br /&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Nothing
        If &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;period.ToLower() = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;monthly&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Then
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal = GetMonthlyReport(id, beginDate, endDate)
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;ElseIf &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;period.ToLower() = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;weekly&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Then
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal = GetWeeklyReport(id, beginDate, endDate)
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;End If
        Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;End Function

    Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetMonthlyReport(location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;br /&gt;                                     beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime, &lt;br /&gt;                                     endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
        Return Nothing
    End Function

    Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetWeeklyReport(location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;br /&gt;                                    beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime, &lt;br /&gt;                                    endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DateTime) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
        Return Nothing
    End Function
End Class
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Consolas" size="2"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;C#
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Get(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;period, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;id, DateTime beginDate, DateTime endDate) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;if &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(period.ToLower() == &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;monthly&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) {
        retVal = GetMonthlyReport(id, beginDate, endDate);
    } &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;else if &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(period.ToLower() == &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;weekly&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;){
        retVal = GetWeeklyReport(id, beginDate, endDate);
    }
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;retVal;
}

&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetMonthlyReport(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;location_Id, DateTime beginDate, DateTime endDate) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return null&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
}
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetWeeklyReport(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;location_Id, DateTime beginDate, DateTime endDate) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return null&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;font color="#000000"&gt;6. Add the GetMonthlyReport LINQ Query&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color="#000000"&gt;From Part 1, you’ll remember we instance the &lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;within a using block to be sure it gets disposed when we’re done. We also call report.Execute() to make sure the LINQ query is executed before the Context is disposed.&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font color="#000000"&gt;&lt;i&gt;Looks like there is a horse before the cart, so we need to get the ordering correct.&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;font color="#000000"&gt;Lastly, we use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.sqlclient.sqlfunctions(v=vs.100).aspx"&gt;SqlFunctions&lt;/a&gt; to create a string format of Month/Year which we need for our Chart to display properly. Using &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.sqlclient.sqlfunctions(v=vs.100).aspx"&gt;SqlFunctions&lt;/a&gt; is important as the query is sent to SQL Server, which wouldn’t know how to parse:&amp;#160; &lt;span style="background: white; color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Format(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0}/{1}&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, x.Key.Month, x.Key.Year)&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Segoe UI"&gt;&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Segoe UI"&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;hr /&gt;VB
&lt;/strong&gt;&lt;/font&gt;&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetMonthlyReport(location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                                 beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                                 endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
   Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateContext()

        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;report = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;From &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;In &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context.DataWorkspace.AmazingPieData.OrderLifeCycles
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Where &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.Order.Location.Location_Id = location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventType_Id = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Complete&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventTime &amp;gt;= beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventTime &amp;lt;= endDate
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Group By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventTime.Year,
                              olc.EventTime.Month,
                              olc.Order.Table.TableType.TableType_Id,
                              olc.Order.Table.TableType.DisplayOrder &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Into Group
                     Order By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Year, Month, DisplayOrder
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Select &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;MonthYear = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert(Month, 2) + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/&amp;quot; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;+                                         &lt;br /&gt;                                        &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert(Year, 4),
                            TableType_Id,
                            Seats = Group.Count()

        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;report.Execute()
    &lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Consolas"&gt;End Using
End Function&lt;/font&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;font size="2"&gt;&lt;strong&gt;C#
&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;private object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetMonthlyReport(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;location_Id, DateTime beginDate, DateTime endDate) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(ServerApplicationContext context = ServerApplicationContext.CreateContext()) {
    var report = context.DataWorkspace.AmazingPieData.OrderLifeCycles
        .Where(olc =&amp;gt; (olc.Order.Location.Location_Id == location_Id) &amp;amp;&amp;amp;
            (olc.EventType_Id == &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Complete&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &amp;amp;&amp;amp;
            (olc.EventTime &amp;gt;= beginDate) &amp;amp;&amp;amp;
            (olc.EventTime &amp;lt;= endDate))
        .GroupBy(x =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{ 
            x.EventTime.Year, 
            x.EventTime.Month, 
            x.Order.Table.TableType.TableType_Id, 
            x.Order.Table.TableType.DisplayOrder })
        .OrderBy(o =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{o.Key.Year, o.Key.Month, o.Key.DisplayOrder})
        .Select(x =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{ 
            MonthYear = SqlFunctions.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) x.Key.Month, 2) + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ 
                SqlFunctions.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)x.Key.Year, 4), 
            TableType_Id = x.Key.TableType_Id, 
            Seats = x.Count() 
        });
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;report.Execute();
    };
}
&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;7. Add the GetWeeklyReport LINQ Query&amp;#160; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The query is very similar to the Monthly report, however this time we’re grouping by the day of the week using the &lt;a href="http://msdn.microsoft.com/en-us/library/dd466176(v=vs.100).aspx"&gt;SqlFunctions&lt;/a&gt; TSQL equivalent of &lt;span style="color: magenta;"&gt;DATEPART&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: teal;"&gt;DW&lt;/span&gt;&lt;span style="color: gray;"&gt;, &lt;/span&gt;&lt;span style="color: teal;"&gt;EventTime&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI" size="2"&gt;&lt;hr /&gt;VB
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetWeeklyReport(location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;br /&gt;                                beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;br /&gt;                                endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
&lt;br /&gt;    Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font size="2"&gt;.CreateContext()
&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;        Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;report = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;From &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;In &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context.DataWorkspace.AmazingPieData.OrderLifeCycles
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Where &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.Order.Location.Location_Id = location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventType_Id = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Complete&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventTime &amp;gt;= beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;AndAlso
                           &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;olc.EventTime &amp;lt;= endDate
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Group By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DayOfWeek = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.DatePart(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DW&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, olc.EventTime),
                              olc.Order.Table.TableType.TableType_Id,
                              olc.Order.Table.TableType.DisplayOrder &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Into Group
                     Order By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DayOfWeek, DisplayOrder
                     &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Select &lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas"&gt;DayOfWeek,
                            TableType_Id,
                            Seats = Group.Count()&lt;/font&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;report.Execute()
    &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Consolas" size="2"&gt;End Using
End Function&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Segoe UI"&gt;&lt;strong&gt;C#
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;private object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetWeeklyReport(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;location_Id, DateTime beginDate, DateTime endDate) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(ServerApplicationContext context = ServerApplicationContext.CreateContext()) {

        var report = context.DataWorkspace.AmazingPieData.OrderLifeCycles
            .Where(olc =&amp;gt; (olc.Order.Location.Location_Id == location_Id) &amp;amp;&amp;amp;
                (olc.EventType_Id == &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Complete&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &amp;amp;&amp;amp;
                (olc.EventTime &amp;gt;= beginDate) &amp;amp;&amp;amp;
                (olc.EventTime &amp;lt;= endDate))
            .GroupBy(x =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{ 
                DayOfWeek = SqlFunctions.DatePart(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DW&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, x.EventTime), 
                x.Order.Table.TableType.TableType_Id, 
                x.Order.Table.TableType.DisplayOrder
            })
            .OrderBy(o =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{o.Key.DayOfWeek, o.Key.DisplayOrder})
            .Select(x =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                DayOfWeek = x.Key.DayOfWeek,
                TableType_Id = x.Key.TableType_Id,
                Seats = x.Count()
            });
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;report.Execute();
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;h2&gt;Testing with Fiddler&lt;/h2&gt;

&lt;p&gt;Let’s do our normal Fiddler testing to be sure we have this portion correct before delving into javascript&lt;/p&gt;

&lt;p&gt;1. Hit F5 to get the base URL of your app&lt;/p&gt;

&lt;p&gt;2. Launch Fiddler and paste the base URL into the Composer&lt;/p&gt;

&lt;p&gt;&lt;i&gt;3. &lt;/i&gt;Modify it to include the following query string.&amp;#160;&amp;#160; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;u&gt;&lt;strong&gt;http://localhost:30550&lt;/strong&gt;/reports/seatedGuests/?period=monthly&amp;amp;id=BelSquare%20&amp;amp;beginDate=2010-05-07&amp;amp;endDate=2013-02-23&lt;/u&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note that we have period =monthly, and we’ve set the begin/endDate using the JSON serialized format. 
    &lt;br /&gt;&lt;i&gt;(I’ve removed the time since we zero it out anyway)&lt;/i&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;b&gt;Tip:&lt;/b&gt; Had I not tested the output with Fiddler, I wouldn’t have noticed that &lt;a href="http://msdn.microsoft.com/en-us/library/dd487110(v=vs.100).aspx"&gt;SqlFunctionsStringConvert&lt;/a&gt; was padding the month &amp;amp; year&lt;/p&gt;
&lt;/blockquote&gt;
&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;/font&gt;

&lt;table cellspacing="0" cellpadding="2" width="716" border="1"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="354"&gt;Without setting the string length&lt;/td&gt;

      &lt;td valign="top" width="360"&gt;Using the StringConvert overload to set the length&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="354"&gt;
        &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="1"&gt;&lt;span style="background: white; color: black;"&gt;MonthYear = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) x.Key.Month)  
  + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+   &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)x.Key.Year)
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
        &lt;font size="1"&gt;&lt;/font&gt;&lt;/td&gt;

      &lt;td valign="top" width="360"&gt;&lt;font size="1"&gt;&lt;/font&gt;

        &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="1"&gt;&lt;span style="background: white; color: black;"&gt;MonthYear = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) x.Key.Month&lt;font style="background-color: rgb(255, 255, 0);"&gt;, 2&lt;/font&gt;)
    + &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlFunctions&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StringConvert((&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)x.Key.Year&lt;font style="background-color: rgb(255, 255, 0);"&gt;, 4&lt;/font&gt;)
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
        &lt;font size="1"&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="354"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7217.image_5F00_2CFEC6BD.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5164.image_5F00_thumb_5F00_2FA7826E.png" width="335" height="302" /&gt;&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="360"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4113.image_5F00_7858B657.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0312.image_5F00_thumb_5F00_713979DF.png" width="335" height="302" /&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;h2&gt;Adding the Graphs&lt;/h2&gt;

&lt;p&gt;With our WebAPI Reporting Service tested and ready, let’s add the new graphs&lt;/p&gt;

&lt;p&gt;1. Switch back to Logical View&lt;/p&gt;

&lt;p&gt;2. Open the &lt;b&gt;Locaion_View&lt;/b&gt; screen&lt;/p&gt;

&lt;p&gt;3. Select the &lt;b&gt;Report Tab Rows Layout&lt;/b&gt; control to get the &lt;b&gt;add&lt;/b&gt; control menu and select New Custom Control…&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1882.image_5F00_7F0BBFDA.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2553.image_5F00_thumb_5F00_5EF0B31D.png" width="299" height="292" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4. Using the property sheet, rename it &lt;b&gt;ServedGuests&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3124.image_5F00_6CC2F918.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8322.image_5F00_thumb_5F00_7A953F13.png" width="247" height="104" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5. Choose &lt;b&gt;Write Code&lt;/b&gt; –&amp;gt; &lt;b&gt;ServedGuests_render&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;6. Add the following code to create the chart containers &amp;lt;div/&amp;gt; tags&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: &lt;font color="#a5a5a5"&gt;greyed out code &lt;/font&gt;indicates the previous code as the insertion reference point&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#666666"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;hr /&gt;myapp.Location_View.ServedGuests&lt;/font&gt;&lt;font color="#a5a5a5"&gt;_render &lt;/font&gt;&lt;font color="#a5a5a5"&gt;= &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;(element, contentItem) {
&lt;/font&gt;    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Each KendoUI chart needs it's own container
    // One for the Monthly graph
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;customersPerMonthChartContainer = $(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'&amp;lt;div/&amp;gt;'&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;);
    customersPerMonthChartContainer.appendTo($(element));

    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// One for the weekly charts.
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;customersPerWeekChartContainer = $(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'&amp;lt;div/&amp;gt;'&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;);
    customersPerWeekChartContainer.appendTo($(element));
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;p&gt;7. Add Kendo UI Chart Control for the Monthly Report&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Note &lt;/strong&gt;that for now, we’re hardcoding the date range. We’ll build this up slowly to avoid tripping over coding issues with things like javascript dates. We’ve also placed this within a function, which we call immediately. Later on, we’ll add the ability to change the date range, and for each date change, we’ll want to redraw the chart.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;&lt;font color="#a5a5a5"&gt;displayMonthlyChart()
&lt;/font&gt;
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;displayMonthlyChart() {
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//setup the URI to the report, with the Location Parameter, and the date range
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportsAPI = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;../reports/seatedGuests/?period=monthly&amp;amp;id=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.Location.Location_Id +
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;beginDate=2010-07-20&amp;amp;endDate=2013-01-04&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;

    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Add a Kendo UI BarChart
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;customersPerMonthChartContainer.kendoChart({
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// set the theme
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;theme: $(document).data(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;kendoSkin&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) || &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Set the sourc to use our WebAPI, with a json payload
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dataSource: {
            transport: {
                read: {
                    url: reportsAPI,
                    dataType: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;json&amp;quot;
                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
            },
            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// use the TableType_Id to create groupings in the chart
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;group: {
                field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        title: {
            text: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Customers Per Month, By Table Type&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
        legend: {
            position: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;bottom&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Set the chart to a column (vertical) report type
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;seriesDefaults: {
            type: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;column&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            labels: {
                visible: &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;true&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// the 0:n0 means parameterize the label with the value - first 0
                // and then :n0 means use numeric with 0 decimals
                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0:n0}&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// map the vertical series to the number of seats, 
        // notice the field: &amp;quot;Seats&amp;quot; matches the name in the json payload returned from our WebAPI
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;series: [{
            field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            name: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            colorField: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;userColor&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            labels: {
                rotation: 320
            }
        }],
        valueAxis: {
            labels: {
                format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0}&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// And the category is grouped by Month, also from our WebAPI json payload
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;categoryAxis: {
            field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;MonthYear&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            labels: {
                &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//format: &amp;quot;{0:n0}&amp;quot;
                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0}&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                rotation: 300
            }
        }
    }); &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Close of Kendo Monthly Chart
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;}&lt;/font&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;8. Let’s F5 to see how things work so far:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1376.image_5F00_535AF5DE.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4606.image_5F00_thumb_5F00_2EC9685A.png" width="897" height="772" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not so bad. We have quite a lot of data here, visually presented, allowing your users to know where to drill in, looking for more details.&lt;/p&gt;

&lt;h2&gt;Add Weekly Chart&lt;/h2&gt;

&lt;p&gt;We can see how the Bel Square location is trending during the year, but what about weekly, for a given month? We’ll now add another chart that will display the averaged seated guests, by day of the week for the month the user clicks on.&lt;/p&gt;

&lt;p&gt;1. Add the displayWeeklyChart function, just blow our Monthly chart, and still within the render method 
  &lt;br /&gt;

  &lt;br /&gt;Note: we’re still commenting out the date ranges as we’ll plumb this through once we get the basic charts displayed. I’ve also placed the weekly chart within a function as we only want to show this chart when the user clicks on a time period within the monthly chart. Each time they click a different time slice, we’ll want to update the chart by calling the displayWeeklyChart function. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#a5a5a5"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;hr /&gt;        }
&lt;/font&gt;&lt;font color="#a5a5a5"&gt;    }); &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: green;"&gt;&lt;font color="#a5a5a5"&gt;// Close of Kendo Monthly Chart 
&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;}&lt;/font&gt;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;displayWeeklyChart(beginDate, endDate) {
    customersPerWeekChartContainer.fadeIn(500);
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//setup the URI to the report, with the Location Parameter, and the date range
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportsAPI = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;../reports/SeatedGuests/?period=weekly&amp;amp;id=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ &lt;br /&gt;        contentItem.screen.Location.Location_Id +
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;beginDate=2010-07-20&amp;amp;endDate=2013-01-04&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
  &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;customersPerWeekChartContainer.kendoChart({
        theme: $(document).data(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;kendoSkin&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) || &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        dataSource: {
&lt;/span&gt;&lt;span style="background: white; color: green;"&gt;            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;transport: {
                read: {
                    url: reportsAPI,
                    dataType: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;json&amp;quot;
                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
            },
            group: {
                field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        title: {
            text: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Customers Per Week, By Table Type&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
        legend: {
            position: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;bottom&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
        seriesDefaults: {
            type: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;column&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            labels: {
                visible: &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;true&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0:n0}&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        series: [{
            field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            name: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            colorField: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;userColor&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}],
        valueAxis: {
            labels: {
                format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0}&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        },
        categoryAxis: {
            field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
    });
};
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;h3&gt;Add a Click Event Handler to the Bar Chart&lt;/h3&gt;

&lt;p&gt;To drill into the data, we’ll enable click events on the chart. Most charts support this powerful feature. &lt;/p&gt;

&lt;p&gt;1. Below the configuration of the Monthly chart, we’ll add the seriesClick event handler &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;categoryAxis: {
            field: &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;MonthYear&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;font color="#a5a5a5"&gt;,
&lt;/font&gt;            labels: {&lt;/font&gt;
                &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;&lt;font color="#a5a5a5"&gt;//format: &amp;quot;{0:n0}&amp;quot;
&lt;/font&gt;                &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;format: &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;{0}&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;,
&lt;/font&gt;                &lt;font color="#a5a5a5"&gt;rotation: 300
&lt;/font&gt;&lt;font color="#a5a5a5"&gt;            }
&lt;/font&gt;        }, &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// &amp;lt;-- note the comma to continue the configuration of the chart
        // hook up the Click event to drill into weekly reports
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;seriesClick: onSeriesClick
    }); &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Close of Kendo Monthly Chart
&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;onSeriesClick(e) {
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Split the category label into Month/Year
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dateElements = e.category.split(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;);
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// javascript uses Month 0 as January - so, start from Jan, 
    // and add the selected month, which needs to be decremented to account for 0 base javascript
    // compared to the rest of the human readable world
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;beginDate = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Date(dateElements[1], parseInt(dateElements[0]) - 1, 1);
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;endDate = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Date(beginDate.getFullYear(), beginDate.getMonth() + 1, &lt;br /&gt;                           beginDate.getDate(), beginDate.getHours());
    displayWeeklyChart(beginDate, endDate);
}

&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;font face="Consolas" size="2"&gt;displayWeeklyChart(beginDate, endDate) {
    customersPerWeekChartContainer.fadeIn(500);&lt;/font&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;h2&gt;Adding Date Parameters&lt;/h2&gt;

&lt;p&gt;We’ll now add begin and endDate controls to narrow the results. &lt;/p&gt;

&lt;h3&gt;Adding Screen Parameters&lt;/h3&gt;

&lt;p&gt;We’ll want these values to come from the user, and don’t forget, LightSwitch uses a ViewModel approach&lt;/p&gt;

&lt;p&gt;1. Open the Location_View screen&lt;/p&gt;

&lt;p&gt;2. In the Reports Tab, add a new Group&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Name it dateRange&lt;/li&gt;

  &lt;li&gt;Change the Group to Column layout&lt;/li&gt;

  &lt;li&gt;Move it below the Served Guests custom control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3. Add two new screen properties &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;On the top of the screen designer, select Add Data Item…&lt;/li&gt;

  &lt;li&gt;Change the Member Type to Local Property&lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;Type = Date&lt;/li&gt;

    &lt;li&gt;Uncheck Is Required&lt;/li&gt;

    &lt;li&gt;and name it beginDate&lt;/li&gt;
  &lt;/ul&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3124.clip_5F00_image001_5F00_2E5D3565.png"&gt;&lt;img title="clip_image001" style="display: inline; background-image: none;" border="0" alt="clip_image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8836.clip_5F00_image001_5F00_thumb_5F00_3105F116.png" width="504" height="504" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add another optional local property for endDate with the same options&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4. Add beginDate and endDate screen properties as controls on the screen&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Below the date Range Columns Layout (grouping), click the add button to add the two local properties&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3630.clip_5F00_image0024_5F00_42E284E3.png"&gt;&lt;img title="clip_image002[4]" style="display: inline; background-image: none;" border="0" alt="clip_image002[4]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1376.clip_5F00_image0024_5F00_thumb_5F00_49958E66.png" width="237" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change the Control Types to Date Picker for both of the screen parameters&lt;/li&gt;

  &lt;li&gt;You’re screen designer should now look like this…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6170.clip_5F00_image0034_5F00_653A1A5C.png"&gt;&lt;img title="clip_image003[4]" style="display: inline; background-image: none;" border="0" alt="clip_image003[4]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7750.clip_5F00_image0034_5F00_thumb_5F00_7716AE29.png" width="285" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5. Lets set the default values for the date range properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;From the Write Code menu, select &lt;strong&gt;&lt;u&gt;created&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3058.image_5F00_19DA7698.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6685.image_5F00_thumb_5F00_12BB3A20.png" width="573" height="146" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Default the beginning date to the date the location opened for business and the end date to today 
    &lt;br /&gt;While we’re here, we’ll also set the screen display name to the Id of the location&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;hr /&gt;myapp.Location_View.created &lt;/font&gt;&lt;font color="#a5a5a5"&gt;= &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;(screen) {
&lt;/font&gt;    screen.beginDate = screen.Location.LocationOpened;
    screen.endDate = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Date();
    screen.details.displayName = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Location: &amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ screen.Location.Location_Id;
};
&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;6. &lt;/i&gt;Change our Monthly Chart to use the new screen parameters&amp;#160;&amp;#160; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;i&gt;&lt;strong&gt;Note&lt;/strong&gt;: we use the Date.toJSON() function to convert the date to a format that will serialize across URLs.&lt;/i&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;function &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;font face="Consolas" size="2"&gt;displayMonthlyChart() {
&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;    if &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(contentItem.screen.endDate &amp;lt; contentItem.screen.beginDate) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;    var &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;reportsAPI = &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;../reports/seatedGuests/?period=monthly&amp;amp;id=&amp;quot; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;+ &lt;br /&gt;         contentItem.screen.Location.Location_Id +
&lt;/font&gt;        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;beginDate=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.beginDate.toJSON() +
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;endDate=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.endDate.toJSON();
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;/pre&gt;
&lt;font size="2" face="Consolas"&gt;
  &lt;hr /&gt;&lt;/font&gt;

&lt;p&gt;7. Lets hange the displayWeeklyChart() to also use the date range screen parameters by replacing the fixed date with the begin/end date parameters. Note the toJSON() conversion to make sure we encode the dates for URLs&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;hr /&gt;&lt;font color="#a5a5a5" face="Consolas" size="2"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;displayWeeklyChart() {
&lt;/font&gt;&lt;font color="#a5a5a5"&gt;    &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: green;"&gt;&lt;font color="#a5a5a5"&gt;//setup the URI to the report, with the Location Parameter, and the date range
    &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;var &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;reportsAPI = &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;../reports/SeatedGuests/?period=weekly&amp;amp;id=&amp;quot; &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;+ &lt;br /&gt;        &lt;/font&gt;&lt;font color="#a5a5a5"&gt;contentItem.screen.Location.Location_Id +
&lt;/font&gt;        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;beginDate=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.beginDate.toJSON() +
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;amp;endDate=&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.endDate.toJSON();
&lt;br /&gt;&lt;font color="#a5a5a5"&gt;    customersPerWeekChartContainer.kendoChart({
&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;p&gt;8. We’ll now Databind the date ranges to re-display the monthly report when the dates change. We’ll also&amp;#160; hide the chart until the user re-clicks a monthly slice.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: green;"&gt;&lt;hr /&gt;&lt;font color="#a5a5a5" face="Consolas" size="2"&gt;// add the whole thing to the LightSwitch custom control
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;customersByTableTypeContainer.appendTo($(element));
&lt;/font&gt;
&lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Databind the date range changes to rebuild the chart
&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;contentItem.dataBind(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;screen.beginDate&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;() {
    customersPerWeekChartContainer.fadeOut(500);
    displayMonthlyChart();
});
contentItem.dataBind(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;screen.endDate&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;() {
    customersPerWeekChartContainer.fadeOut(500);
    displayMonthlyChart();
});
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5" face="Consolas" size="2"&gt;displayMonthlyChart();
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;hr /&gt;&lt;i&gt;&lt;/i&gt;

&lt;p&gt;Run it and notice that now you can click on a month to get the weekly breakdown and when we change the dates, the charts will refresh. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8203.image_5F00_31532EDC.png"&gt;&lt;img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4314.image_5F00_thumb_5F00_2C04482B.png" width="538" height="566" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;U&lt;/b&gt;&lt;b&gt;sing Stored Procedures &lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;Since reporting is typically based on aggregating large amounts of data, and you may be working with existing systems, your DBA may already have several stored procedures created, and you just need to return the results. Lets replace the weekly query with a stored procedure.&lt;/p&gt;

&lt;h3&gt;Getting the Connection String&lt;/h3&gt;

&lt;p&gt;To call the stored procedure, we’re going to use the traditional ADO.net objects directly. SqlConnection, SqlCommand and SqlDataReader. Of course, we need a connection string which we’ll read from the ConfigurationManager. This requires an additional reference.&lt;/p&gt;

&lt;p&gt;1. From the File view, select &lt;strong&gt;Add Reference &lt;/strong&gt;on the Server project&lt;/p&gt;

&lt;p&gt;2. Check off System.Configuration&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5164.image_5F00_04C5EFD8.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8304.image_5F00_thumb_5F00_6E06A84E.png" width="605" height="417" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3. Open the SeatedGuestsController&lt;/p&gt;

&lt;p&gt;4. Add the using/import statements for referencing the SQL ADO.net objects and the System.Configuration namespace&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;&lt;hr /&gt;VB
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Configuration
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data.SqlClient
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;font face="Segoe UI" size="2"&gt;&lt;strong&gt;C#
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Configuration;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Data.SqlClient;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;p&gt;5. Modify the GetWeeklyReport code to call the stored procedure&lt;/p&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Segoe UI"&gt;&lt;font size="2"&gt;&lt;strong&gt;VB
&lt;/strong&gt;&lt;/font&gt;&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;GetWeeklyReport(location_Id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                                beginDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
                                endDate &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object

    Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateContext()

        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;conn &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlConnection &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;=
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ConfigurationManager&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.ConnectionStrings(
                context.DataWorkspace.AmazingPieData.Details.Name).ConnectionString)

            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;cmd &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;()
            cmd.Connection = conn
            cmd.CommandText = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;GetSeatedGuestsPerTableTypePerLocationByWeekday&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;cmd.CommandType = &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CommandType&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.StoredProcedure
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlParameter&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@location_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, location_Id))
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlParameter&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@beginDateRange&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, beginDate))
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlParameter&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@endDateRange&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, endDate))
            cmd.Connection.Open()

            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reader &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;SqlDataReader &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= cmd.ExecuteReader(&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;CommandBehavior&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CloseConnection)

                &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult = (&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;From &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dr &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;In &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reader.Cast(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Of &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;IDataRecord&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)()
                                    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Select &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DayOfWeek = dr.GetInt32(0),
                                           TableType_Id = dr.GetString(1),
                                           Seats = dr.GetInt32(2)).ToList()

                &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult
            &lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Consolas"&gt;End Using
        End Using
    End Using
End Function&lt;/font&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;C#
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;private object &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;GetWeeklyReport(&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font color="#a5a5a5"&gt;string &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;location_Id, DateTime beginDate, DateTime endDate) {
&lt;/font&gt;    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(ServerApplicationContext context = ServerApplicationContext.CreateContext()) {
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(SqlConnection conn = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;SqlConnection(ConfigurationManager.ConnectionStrings&lt;br /&gt;               [context.DataWorkspace.AmazingPieData.Details.Name].ConnectionString)) {
            SqlCommand cmd = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;GetSeatedGuestsPerTableTypePerLocationByWeekday&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;SqlParameter(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@location_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, location_Id));
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;SqlParameter(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@beginDateRange&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, beginDate));
            cmd.Parameters.Add(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;SqlParameter(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;@endDateRange&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, endDate));
            cmd.Connection.Open();
            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Execute the reader into a new named type to be json serialized
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) {
                reportResult = reader.Cast&amp;lt;IDataRecord&amp;gt;()
                                .Select(dr =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                                    DayOfWeek = dr.GetInt32(0),
                                    TableType_Id = dr.GetString(1),
                                    Seats = dr.GetInt32(2)
                                    }
                                    ).ToList();
            }
        }
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult;
    }
}
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h2&gt;Bonus Round&lt;/h2&gt;

&lt;p&gt;In case you’re still reading, and not ready to leave, I’ve got one more enhancement. It sure would be nice to display the names of the week.&amp;#160; &lt;/p&gt;

&lt;h3&gt;&lt;b&gt;Changing the Weekly chart to show days of the week&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;1. In the displayWeeklyChart, add the following code to the displayWeeklyChart function to create an array for the days of the week, and use the Kendo chart dataBound event to convert the array to the categories of the chart.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: rgb(165, 165, 165);"&gt;&lt;hr /&gt;function &lt;/span&gt;&lt;span&gt;&lt;font color="#a5a5a5"&gt;displayWeeklyChart(beginDate, endDate) {
    &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white;"&gt;&lt;font color="#a5a5a5"&gt;//setup the URI to the report, with the Location Parameter, and the date range
&lt;/font&gt;    &lt;/span&gt;&lt;font color="#a5a5a5"&gt;&lt;span style="background: white;"&gt;var &lt;/span&gt;&lt;span style="background: white;"&gt;reportsAPI = &lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;../reports/SeatedGuests/?period=weekly&amp;amp;id=&amp;quot; &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;+ &lt;br /&gt;        contentItem.screen.Location.Location_Id +
&lt;/font&gt;        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;&amp;amp;beginDate=&amp;quot; &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;+ beginDate.toJSON() +
&lt;/font&gt;&lt;font color="#a5a5a5"&gt;        &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font color="#a5a5a5"&gt;&amp;quot;&amp;amp;endDate=&amp;quot; &lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;+ endDate.toJSON();
&lt;/font&gt;
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;daysOfWeekJSON = [
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Mon&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Tues&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Wed&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Thur&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Fri&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Sat&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
                        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;DayOfWeek&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Sun&amp;quot; &lt;/span&gt;&lt;span&gt;}];

&lt;font color="#a5a5a5"&gt;    customersPerWeekChartContainer.kendoChart({
        theme: $(document).data(&lt;/font&gt;&lt;/span&gt;&lt;font color="#a5a5a5"&gt;&lt;span&gt;&amp;quot;kendoSkin&amp;quot;&lt;/span&gt;&lt;span&gt;) || &lt;/span&gt;&lt;span&gt;&amp;quot;black&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#a5a5a5"&gt;&lt;span&gt;,&lt;br /&gt;        dataSource: {
        },
        categoryAxis: {
            field: &lt;/span&gt;&lt;span&gt;&amp;quot;DayOfWeek&amp;quot;
        &lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font color="#a5a5a5"&gt;},
&lt;/font&gt;        dataBound: dataBound
&lt;font color="#a5a5a5"&gt;    });
&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;  function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dataBound(e) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;chart = e.sender,
        categories = chart.options.categoryAxis.categories,
        weekNumber;

    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;for &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;i = 0; i &amp;lt; categories.length; i++) {
        weekNumber = categories[i];
        categories[i] = daysOfWeekJSON[weekNumber - 1].DayOfWeek;
    }
  }&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;};
&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h2&gt;Wrapping it up&lt;/h2&gt;

&lt;p&gt;Visual Studio LightSwitch enables rapid productivity for the common components of your app. However, all apps are not created equal. With our extensibility points, developers can take their app in the direction they need, including rich visualizations, leveraging aggregate data from the data source to pixels on the screen.&lt;/p&gt;

&lt;p&gt;By leveraging WebAPI, the new aggregate LINQ operators within LightSwitch, the ServerApplicationContext and some great chart controls, we can stitch together some great experiences, building on the “out of the box” features.&lt;/p&gt;

&lt;p&gt;With some ADO.net code, we can utilize stored procedures to generate the reports, making sure our DBAs are happy leveraging the power of database query processors. Using parameters, we can narrow the results required by the user, allowing them to drill into specific slices of data.&lt;/p&gt;

&lt;p&gt;I hope this blog was helpful and please continue to give us great feedback here and &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/lightswitch/threads" target="_blank"&gt;in the forum&lt;/a&gt; on what works, what’s tripping you up, and what we should do more of so we can keep you and your customers productive.&lt;/p&gt;

&lt;p&gt;Steve Lasker&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/SteveLasker"&gt;http://blogs.msdn.com/SteveLasker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Program Manager, Visual Studio LightSwitch&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10413542" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/How_2D00_To/">How-To</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML/">HTML</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Data/">Data</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/API/">API</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/WebAPI/">WebAPI</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Steve+Lasker/">Steve Lasker</category></item><item><title>Create Dashboard Reports with LightSwitch, WebAPI and ServerApplicationContext (Steve Lasker)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/04/22/create-dashboard-reports-with-lightswitch-webapi-and-serverapplicationcontext.aspx</link><pubDate>Mon, 22 Apr 2013 16:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10411722</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10411722</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/04/22/create-dashboard-reports-with-lightswitch-webapi-and-serverapplicationcontext.aspx#comments</comments><description>&lt;h1&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/h1&gt;  &lt;p&gt;Applications are creating and consuming more data than ever before. With so much data, how can your users quickly spot trends and get an overview of what’s important? Just as your car presents a dashboard indicating the top priority items, so can your application.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2013/04/15/using-serverapplicationcontext.aspx" target="_blank"&gt;Matt introduced the ServerApplicationContext&lt;/a&gt; in his blog post. This article will build on it to show how to build rich dashboard and reporting apps using LINQ aggregate operators, returning data via WebAPI in a JSON format. &lt;/p&gt;  &lt;p&gt;Noticing the length of this post, it’s fair to say this isn’t the normal point &amp;amp; click RAD productivity you’ve likely become used to with LightSwitch. This is more of an advanced scenario, showing the extension points we’ve enabled to extend the out of the box features.&lt;/p&gt;  &lt;p&gt;There will be several steps, so let’s recap what we’ll be covering&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a Restaurant Point Of Sale (POS) database for reporting&lt;/li&gt;    &lt;li&gt;Creating an initial Ligthswitch App, adding a few screens to provide navigation to our graphs&lt;/li&gt;    &lt;li&gt;Add a LightSwitch custom control to display a Kendo UI DataViz Bar Graph&lt;/li&gt;    &lt;li&gt;Add WebAPIs for reporting&lt;/li&gt;    &lt;li&gt;Test the WebAPIs with Fiddler&lt;/li&gt;    &lt;li&gt;Connect the HTML Client Graph to the WebAPI report&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s get started&lt;/p&gt;  &lt;h1&gt;&lt;strong&gt;Create the Amazing Pie Restaurant Point of Sale (POS) database&lt;/strong&gt;&lt;/h1&gt;  &lt;p&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Lightswitch-AmazingPie-6b4665c6"&gt;AmazingPie POS Sample database&lt;/a&gt;&lt;/p&gt;  &lt;h1&gt;Creating the LightSwitch Project&lt;/h1&gt;  &lt;p&gt;We’ll need a basic app to put the reports within. The app will be fairly straight forward with a few screens using the externally linked Amazing Pie database.&lt;/p&gt;  &lt;ol&gt;&lt;/ol&gt;  &lt;p&gt;1. First, create a new &lt;strong&gt;Lightswtich HTML Application&lt;/strong&gt; (C# or Visual Basic) named &lt;strong&gt;AmazingPieManager&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5023.CreatenewProject_5F00_1048E1FD.png"&gt;&lt;img title="CreatenewProject" style="display: inline; background-image: none;" border="0" alt="CreatenewProject" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2112.CreatenewProject_5F00_thumb_5F00_72D690F0.png" width="644" height="446" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;ol&gt;&lt;/ol&gt;  &lt;p&gt;2. Select “Attach to external data source”, connecting to the AmazingPie database we’ve just created    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0068.AttachToExternalData_5F00_79899A73.png"&gt;&lt;img title="AttachToExternalData" style="display: inline; background-image: none;" border="0" alt="AttachToExternalData" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1538.AttachToExternalData_5F00_thumb_5F00_596E8DB6.png" width="385" height="97" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3. Select “Database”&lt;/p&gt;  &lt;p&gt;4. Enter the connection information for your AmazingPie database&lt;/p&gt;  &lt;p&gt;5. Select all the tables    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3276.ConsumeDatabaseObjects_5F00_395380F9.png"&gt;&lt;img title="ConsumeDatabaseObjects" style="display: inline; background-image: none;" border="0" alt="ConsumeDatabaseObjects" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3288.ConsumeDatabaseObjects_5F00_thumb_5F00_0E0EE9F2.png" width="580" height="454" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;6. Verify the Data Source is named &lt;strong&gt;AmazingPieData&lt;/strong&gt;, and click [Finish] &lt;/p&gt;  &lt;h1&gt;Build some viewing screens&lt;/h1&gt;  Before we create the graphs, we’ll need some screens to navigate around the application .   &lt;h2&gt;Locations Browse Screen&lt;/h2&gt;  &lt;p&gt;1. Right-click on the HTML Client node in the Solution Explorer and select “Add Screen”&lt;/p&gt;  &lt;p&gt;2. Select the &lt;strong&gt;“Browse Data Screen”&lt;/strong&gt; template, using the &lt;strong&gt;“AmazingPieData.Locations”&lt;/strong&gt; entity as a Data Source &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Personally, I prefer all my screens grouped together by name, then type, so I’ll rename the screen &lt;strong&gt;Locations_Browse        &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0640.AddNewScreenLocations_5F00_Browse_5F00_06EFAD7A.png"&gt;&lt;img title="AddNewScreenLocations_Browse" style="display: inline; background-image: none;" border="0" alt="AddNewScreenLocations_Browse" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4452.AddNewScreenLocations_5F00_Browse_5F00_thumb_5F00_5BAB1672.png" width="644" height="460" /&gt;&lt;/a&gt;&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;3. We’ll change the default display a bit: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Change the Display type from &lt;strong&gt;List&lt;/strong&gt; to &lt;strong&gt;Tile List        &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2318.image_5F00_1B74FCF8.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8475.image_5F00_thumb_5F00_7B59F03A.png" width="297" height="185" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Reduce the properties to be displayed      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6332.image_5F00_5B3EE37D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4278.image_5F00_thumb_5F00_3B23D6C0.png" width="293" height="255" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;ul&gt;&lt;/ul&gt; &lt;/ul&gt;  &lt;h2&gt;Locations View Screen&lt;/h2&gt;  &lt;p&gt;1. Right-click on the HTML Client node in the Solution Explorer and select “Add Screen”&lt;/p&gt;  &lt;p&gt;2. Select the &lt;strong&gt;“View Details Screen”&lt;/strong&gt; template, using the &lt;strong&gt;“AmazingPieData.Location”&lt;/strong&gt; entity as a Data Source &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We’ll name this &lt;strong&gt;Location_View&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Add additional data including Location Tables and &lt;strong&gt;click [OK]        &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1538.image_5F00_1B08CA03.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7080.image_5F00_thumb_5F00_6FC432FB.png" width="604" height="431" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;3. We’ll change the default display a bit:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a Columns Layout group &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Move City, State, Zip below this group&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Change the Tables to a Tile List &lt;/li&gt;    &lt;li&gt;Reduce the properties to Table Id, Table Type and Table Size&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;I’ve also shortened the list of properties to Type and Size and moved Size last&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;When done, you’re layout should look like this:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2703.image_5F00_447F9BF4.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8154.image_5F00_thumb_5F00_0449827A.png" width="346" height="692" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Link the screens through Item Tap&lt;/h2&gt;  &lt;p&gt;We need to navigate from one screen to another, and we do that with &lt;u&gt;Item Tap&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;1. Open the &lt;strong&gt;Location_Browse&lt;/strong&gt; screen&lt;/p&gt;  &lt;p&gt;2. Select the Tile List for Locations&lt;/p&gt;  &lt;p&gt;3. In the property grid, click &lt;strong&gt;Item Tap &lt;/strong&gt;where it says &lt;u&gt;none&lt;/u&gt;.&lt;/p&gt;  &lt;p&gt;4. Click the dropdown for Choose an existing method&lt;/p&gt;  &lt;p&gt;5. Select &lt;strong&gt;viewSelected      &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0247.LocationBrowseEditItemTapAction_5F00_6E096E29.png"&gt;&lt;img title="LocationBrowseEditItemTapAction" style="display: inline; background-image: none;" border="0" alt="LocationBrowseEditItemTapAction" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3806.LocationBrowseEditItemTapAction_5F00_thumb_5F00_54A16AEF.png" width="530" height="484" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;6. Verify &lt;strong&gt;Navigate To&lt;/strong&gt;: is set to &lt;strong&gt;Location View &lt;/strong&gt;and&lt;strong&gt; click [OK]&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5543.LocationBrowseEditItemTapActionDone_5F00_0941C72B.png"&gt;      &lt;br /&gt;&lt;img title="LocationBrowseEditItemTapActionDone" style="display: inline; background-image: none;" border="0" alt="LocationBrowseEditItemTapActionDone" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3480.LocationBrowseEditItemTapActionDone_5F00_thumb_5F00_02228AB3.png" width="504" height="251" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Add Kendo UI Controls&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;For the purposes of this post, I’m using &lt;a href="http://demos.kendoui.com/dataviz/overview/index.html"&gt;Kendo UI DataViz&lt;/a&gt; controls. There are many great controls and partners we work with, and the meat of this post will be the same regardless of which controls you use.&lt;/p&gt;  &lt;ol&gt;&lt;/ol&gt;  &lt;p&gt;1. Download &lt;a href="http://www.kendoui.com/get-kendo-ui"&gt;Kendo UI&lt;/a&gt;. You can use their 30 day free trial.&lt;/p&gt;  &lt;p&gt;2. Copy the Kendo UI .zip file to a location and for the ease of dragging into Visual Studio, extract the files to another directory&lt;/p&gt;  &lt;p&gt;3. Copy the Kendo UI css and javascript files&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In Visual Studio, toggle from Logical to File View. (Note: the button is a toggle button so you don’t have to actually drop down and select File View)      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7674.SolutionExplorerToggleFileView_5F00_7B034E3A.png"&gt;&lt;img title="SolutionExplorerToggleFileView" style="display: inline; background-image: none;" border="0" alt="SolutionExplorerToggleFileView" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1321.SolutionExplorerToggleFileView_5F00_thumb_5F00_08D59436.png" width="244" height="140" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;With the folder you extracted the Kendo UI files, &lt;strong&gt;open the styles&lt;/strong&gt; folder&lt;/li&gt;    &lt;li&gt;Drag &lt;strong&gt;kendo.dataviz.min.css&lt;/strong&gt; to your &lt;strong&gt;AmazingPieManager.HTMLClient\Content folder        &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8015.clip_5F00_image001_5F00_01B657BE.png"&gt;&lt;img title="clip_image001" style="display: inline; background-image: none;" border="0" alt="clip_image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5050.clip_5F00_image001_5F00_thumb_5F00_045F136F.png" width="644" height="337" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Open the Kendo UI js folder&lt;/li&gt;    &lt;li&gt;Drag &lt;strong&gt;kendo.dataviz.min.js&lt;/strong&gt; to your &lt;strong&gt;AmazingPieManager.HTMLCLient\Scripts&lt;/strong&gt; folder&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3005.image_5F00_7CA7CAD7.png"&gt;&lt;img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2742.image_5F00_thumb_5F00_5C208B25.png" width="648" height="338" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;4. Add the style and js file references    &lt;br /&gt; Since LightSwitch works as a &lt;a href="http://en.wikipedia.org/wiki/Single-page_application"&gt;single page application model&lt;/a&gt;, we’ll just need to &lt;strong&gt;add the references &lt;/strong&gt;to the &lt;strong&gt;default.htm page&lt;/strong&gt;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Open default.htm&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;From the Content\ &lt;strong&gt;drag the kendo.dataviz.min.css file just above the &amp;lt;/head&amp;gt; close &lt;/strong&gt;tag&lt;strong&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;From the \Script directory, &lt;strong&gt;drag the kendo.dataviz.min.js below the last js reference&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;You can also take a moment to add spaces to the page heading of &lt;strong&gt;AmazingPieManager&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Your project should now look like:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5037.clip_5F00_image0016_5F00_05C33641.png"&gt;&lt;img title="clip_image001[6]" style="display: inline; background-image: none;" border="0" alt="clip_image001[6]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1731.clip_5F00_image0016_5F00_thumb_5F00_086BF1F2.png" width="804" height="464" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;&lt;strong&gt;Add Reports Tab&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;With the Kendo UI Control references added, let’s create a place for our graphs&lt;/p&gt;  &lt;p&gt;1. Switch back to the Location_View screen&lt;/p&gt;  &lt;p&gt;2. At the top of the screen designer, Right-Click on Tabs and select &lt;strong&gt;Add Tab      &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0245.clip_5F00_image0018_5F00_1A4885BF.png"&gt;&lt;img title="clip_image001[8]" style="display: inline; background-image: none;" border="0" alt="clip_image001[8]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7181.clip_5F00_image0018_5F00_thumb_5F00_0F1EFB75.png" width="275" height="76" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3. In the properties sheet:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Rename the tab to ReportsTab&lt;/li&gt;    &lt;li&gt;Change the Display Name: to Reports      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5047.image_5F00_1CF14170.png"&gt;&lt;img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6518.image_5F00_thumb_5F00_4EE8E1FA.png" width="244" height="165" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;ol&gt;&lt;/ol&gt;  &lt;p&gt;4. Right-Click on the Reports Tab and select &lt;strong&gt;Add Custom Control&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In the dialog, just select OK for the data path&lt;/li&gt;    &lt;li&gt;In the property grid, rename the custom control SeatedGuests&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;5. Now, add the SeatedGuests render code&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;With the SeatedGuests Custom Control selected, &lt;strong&gt;select SeatedGuests_render&lt;/strong&gt; from the Write Code tab at the top right of the screen designer       &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8255.clip_5F00_image005_5F00_5CBB27F5.png"&gt;&lt;img title="clip_image005" style="display: inline; background-image: none;" border="0" alt="clip_image005" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7587.clip_5F00_image005_5F00_thumb_5F00_03893E36.png" width="327" height="205" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;&lt;strong&gt;Add a Bar Graph &lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;Before we worry about end to end service calls, we can leverage the simplicity of JSON and create some sample data to display&lt;/p&gt;  &lt;ol&gt;&lt;/ol&gt;  &lt;p&gt;1. Add the following code to the SeatedGuests_render function&lt;/p&gt;  &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;myapp.Location_View.SeatedGuests_render = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(element, contentItem) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;sampleData = [
        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Bar&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: 21 },
        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Lounge&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: 23 },
        { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Dining&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: 48 }]&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;2. We’ll now add the &amp;lt;div&amp;gt; to contain the chart, and use jquery to append it to the element passed into the render function&lt;/p&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;hr /&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;locationSeatingChartContainer = $(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'&amp;lt;div/&amp;gt;'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;);
locationSeatingChartContainer.appendTo($(element));&lt;/font&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;3. Add the code for the Kendo UI DataViz Chart &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;locationSeatingChartContainer.kendoChart({
    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: green;"&gt;// set the theme
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;theme: $(document).data(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;kendoSkin&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) || &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// set the datasource to use our sample data for now
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dataSource: {
        data: sampleData
    },
    title: {
        text: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats Per Location&amp;quot;
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
    legend: {
        position: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;bottom&amp;quot;
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;},
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// Set the chart to a column (vertical) report type
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;seriesDefaults: {
        type: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;column&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        labels: {
            visible: &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;true&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// the 0:n0 means parameterize the label with the value - first 0
            // and then :n0 means use numeric with 0 decimals
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0:n0}&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
    },
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// map the vertical series to the number of seats, 
    // notice the field: &amp;quot;Seats&amp;quot; matches the name in the json payload returned from our WebAPI
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;series: [{
        field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        name: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        colorField: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;userColor&amp;quot;
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}],
    valueAxis: {
        labels: {
            format: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;{0:n0}&amp;quot;
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
    },
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// And the category from our WebAPI json payload
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;categoryAxis: {
        field: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;
    &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;}
});&lt;/font&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;4. Now run the app to see how our graph looks 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0513.image_5F00_40AF56A0.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8130.image_5F00_thumb_5F00_0321F8D7.png" width="568" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Create the WebAPI to host the Reporting Service&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Now that we’ve got the UI working, and a place to display our results, let’s create the WebAPI feed.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;If you’re not familiar with &lt;/em&gt;&lt;a href="http://www.asp.net/web-api"&gt;&lt;em&gt;WebAPI&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, you might want to check out the &lt;/em&gt;&lt;a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api"&gt;&lt;em&gt;Getting Started series on the ASP.NET blog&lt;/em&gt;&lt;/a&gt;&lt;em&gt; for a primer on the technology.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;Joe Binder introduced &lt;/em&gt;&lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2012/11/19/a-new-api-for-lightswitch-server-interaction-the-serverapplicationcontext.aspx"&gt;&lt;em&gt;WebAPI to LightSwitch projects&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. I’ll provide the details here for completeness, but I’d suggest reading his post as well.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The basic premise is we’ll create an MVC like convention for calling URLs, routing them to classes that represent services. Depending on the quantity and names of the parameters, the request will be routed to the appropriate method within the class and return our result using the JSON serializer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A note about Project References&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using WebAPI requires a few additional project references:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;Newtonsoft.Json&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Net.Http&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Net.Http.Formatting&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Net.Http.WebRequest&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Web&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Web.Http&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;font size="2" face="Consolas"&gt;&lt;/font&gt;

  &lt;li&gt;&lt;span style="font-family: consolas; font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;font size="2"&gt;System.Web.Http.WebHost&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To eliminate the need to manually add the project references, we’ll take advantage of the Visual Studio Templates that add these automatically. We’ll add the Web API Controller Class first, as it adds most of the references we need, specifically those needed to configure the Web API routing.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Deployment Note: &lt;/em&gt;&lt;/strong&gt;&lt;em&gt;If you want to publish your app to an IIS server, note that you’ll need one extra component. Using the NuGet Package manager on your Server project, add the NuGet package “Microsoft.Web.Infrastructure”. This is installed already on some IIS machines, but not all of them.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;&lt;strong&gt;Nested Folders&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;Joe covered the basics of using WebAPI. As we generate more reports, or use WebAPI for other scenarios, our root folder can get quite filled. To clean things up, we’ll use nested folders and a slightly different configuration for the route.&lt;/p&gt;

&lt;p&gt;1. Toggle the &lt;strong&gt;View&lt;/strong&gt; in Solution Explorer to &lt;strong&gt;File View&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;2. We’ll group all our reports under one folder:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right click on AmazingPieManager.Server and &lt;strong&gt;add a new folder named Reports&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3. Add the WebAPI Reports Controller &lt;/p&gt;

&lt;p&gt;4. Select the AmazingPieManager.Server\Reports folder, and select [add] – [new item] 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0284.clip_5F00_image00219_5F00_70D93214.png"&gt;&lt;img title="clip_image002[19]" style="display: inline; background-image: none;" border="0" alt="clip_image002[19]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4722.clip_5F00_image00219_5F00_thumb_5F00_2C2C97D3.png" width="644" height="448" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5. Select &lt;strong&gt;Web API Controller Class&lt;/strong&gt; from the Web Templates and &lt;strong&gt;name it SeatingController 
    &lt;br /&gt;&lt;/strong&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7534.clip_5F00_image00221_5F00_44BC3523.png"&gt;&lt;img title="clip_image002[21]" style="display: inline; background-image: none;" border="0" alt="clip_image002[21]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8688.clip_5F00_image00221_5F00_thumb_5F00_594184A1.png" width="644" height="447" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6. Before we complete the SeatingController, we’ll &lt;strong&gt;add the Route configuration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;In the root of the project, select Add New Item&lt;/li&gt;

  &lt;li&gt;From the Web Templates, &lt;strong&gt;add the&lt;/strong&gt; &lt;strong&gt;Global Application Class&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3733.clip_5F00_image0048_5F00_02B85693.png"&gt; 
      &lt;br /&gt;&lt;img title="clip_image004[8]" style="display: inline; background-image: none;" border="0" alt="clip_image004[8]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3731.clip_5F00_image0048_5F00_thumb_5F00_69505358.png" width="644" height="447" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;7. Configure the route&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using the naming convention of [name]Controller.cs(.vb), we’ll add a route so we can create URIs similar to: &lt;a href="http://localhost:22700/reports/Seating/BelSquarelkdsj"&gt;http://localhost:22700/reports/Seating/BelSquarelkdsj&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;&lt;a href="http://localhost:22700/reports/Seating/BelSquare"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Note&lt;/span&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;: &lt;/span&gt;&lt;/strong&gt;For more info on Routes see &lt;/em&gt;&lt;em&gt;ASP.net Routing&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;Add the following using statements to the Global.asax file&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;&lt;font face="Segoe UI" size="2"&gt;&lt;strong&gt;VB
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Web.Routing
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Web.Http
&lt;strong&gt;&lt;font face="Segoe UI"&gt;C#
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Web.Routing;
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;System.Web.Http;
&lt;hr /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;8. Add the following route to the &lt;strong&gt;Application_Start &lt;/strong&gt;method&lt;/p&gt;

&lt;hr /&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;&lt;font color="#000000"&gt;VB&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;Sub &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Application_Start(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;ByVal &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;sender &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;ByVal &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;e &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)
    &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;RouteTable&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Routes.MapHttpRoute(
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;ReportsAPI&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;reports/{controller}/{id}&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New With &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Key &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.id = System.Web.Http.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;RouteParameter&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Optional})
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;End Sub
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;strong&gt;&lt;font color="#000000" face="Segoe UI"&gt;C#&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;protected void &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Application_Start(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;sender, &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;EventArgs &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;e) {
    &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;RouteTable&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Routes.MapHttpRoute(
            name: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;ReportsApi&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            routeTemplate: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;reports/{controller}/{id}&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;,
            defaults: &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                id = System.Web.Http.&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;RouteParameter&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.Optional
            }
    );
}
&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;VB Note&lt;/strong&gt;: The MapHttpRoute method is missing from VB intellisense, however it is in the System.Web.Http.dll, so simply type or paste the above text and as long as you’ve followed the steps above for adding the global.asax (adds the System.Web.Http.dll) , and verify you’ve added the imports statements your project should compile.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;9. If everything is added properly, your project should now compile.&lt;/p&gt;

&lt;h1&gt;&lt;strong&gt;Testing WebAPI Calls &amp;amp; Results&lt;/strong&gt;&lt;/h1&gt;

&lt;p&gt;Although WebPAI calls can be made directly in the browser, many browsers fail to display JSON results by default. It’s also helpful to see the HTTP Results code to debug what’s happening under the covers. For the purposes of this post, I’ll use &lt;a href="http://www.fiddler2.com/"&gt;Fiddler&lt;/a&gt; to test and monitor the WebAPI requests rather than fiddle with the browser settings.&lt;/p&gt;

&lt;p&gt;As we’re building out our Reports Controller, and testing with Fiddler to initiate the request, we’ll need the base URL configured.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Setting up Fiddler&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;1. Hit F5 to launch our app and get the root URL. In my case, it’s &lt;a href="http://localhost:22700"&gt;http://localhost:22700&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6254.clip_5F00_image002_5F00_23B3A937.png"&gt;&lt;img title="clip_image002" style="display: inline; background-image: none;" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7725.clip_5F00_image002_5F00_thumb_5F00_0641582B.png" width="233" height="45" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&amp;#160; With your app still running Launch Fiddler&amp;#160;&amp;#160; &lt;/p&gt;

&lt;p&gt;3. Select the Composer tab, and enter &lt;em&gt;[your base URL]&lt;/em&gt;/reports/Seating/1, then hit [Enter] or the [Execute] button 

  &lt;br /&gt;Remembering our route configuration, we’ve configured all requests that start with reports will use the convention of [name]Controller to route our URL to the SeatingController class. The .NET runtime looks for all types that derive from the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.http.apicontroller(v=vs.108).aspx"&gt;ApiController&lt;/a&gt; type. 

  &lt;br /&gt;Since our request is a Get, it’s routed to the Get method. Because we passed a parameter, it’s passed to the Get(int id) overload&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/3122.clip_5F00_image004_5F00_25F031F3.png"&gt;&lt;img title="clip_image004" style="display: inline; background-image: none;" border="0" alt="clip_image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8311.clip_5F00_image004_5F00_thumb_5F00_2CA33B76.png" width="769" height="191" /&gt;&lt;/a&gt;4. If you double click the Web Session, click on the Raw tab for result formatting, you’ll see “value” returned from our basic WebAPI controller.&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7725.clip_5F00_image006_5F00_335644F9.png"&gt;&lt;img title="clip_image006" style="display: inline; background-image: none;" border="0" alt="clip_image006" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1067.clip_5F00_image006_5F00_thumb_5F00_1C96FD70.png" width="767" height="447" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Testing a JSON result&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;With the basics running, let’s crate a simple collection and return it to see how this looks in Fiddler, and ultimately how our HTML client will receive it.&lt;/p&gt;

&lt;p&gt;1. Open the SeatingController from our &lt;strong&gt;AmazingPieManager.Server&lt;/strong&gt; project and delete all the generated methods.&lt;/p&gt;

&lt;p&gt;2. Since we’re returning an anonymous type, we need to change the return type from string to object&lt;/p&gt;

&lt;p&gt;3. Add the following code to construct a collection and return it:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;font color="#424242"&gt;&lt;font size="2"&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;strong&gt;&lt;font color="#000000" face="Segoe UI"&gt;&lt;hr /&gt;VB&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;[Get](id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Integer&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
    Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;myList &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Of String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Integer&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;New &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Of String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Integer&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;)
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Bar&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 21)
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Lounge&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 23)
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Dining&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 48)

    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;result = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;From &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;r &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;In &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;myList
                 &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Select New With &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{.TableType_Id = r.Key, .Seats = r.Value}

    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;result
&lt;/span&gt;&lt;/font&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Consolas"&gt;End Function&lt;/font&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;&lt;font face="Segoe UI"&gt;&lt;strong&gt;&lt;font color="#000000"&gt;C#&lt;/font&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;public object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Get(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;int &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;id) {
    Dictionary&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;int&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&amp;gt; myList = &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Dictionary&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;int&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;&amp;gt;();
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Bar&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 21);
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Lounge&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 23);
    myList.Add(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Dining&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, 48);
 
    var result = (from r &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;in &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;myList
                    select &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{ TableType_Id = r.Key, Seats = r.Value });
 
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;result;
}&lt;/font&gt;
&lt;hr /&gt;&lt;font color="#424242" face="Segoe UI"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;What we’ve done above is create a simple dictionary of name/value pairs 
  &lt;br /&gt;Then, using LINQ, construct a new type, with named properties, correlating to the key and values of our dictionary. 

  &lt;br /&gt;Because the project defaults to the JSON serializer, we’ll see the results below.&lt;/p&gt;

&lt;p&gt;1. Build the project. Note: It’s not actually necessary to hit F5, although you can and set a breakpoint in the Get method.&lt;/p&gt;

&lt;p&gt;2. From Fiddler, hit execute to make the HTTP Get Request.&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2860.clip_5F00_image0025_5F00_42F8E0BB.png"&gt;&lt;img title="clip_image002[5]" style="display: inline; background-image: none;" border="0" alt="clip_image002[5]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8814.clip_5F00_image0025_5F00_thumb_5F00_4C54A5EF.png" width="767" height="447" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3. This time, Fiddler notices the JSON payload and defaulted the formatting to JSON. You can also switch to TextView, WebView or Raw to see it formatted in a typical JSON format that you may remember seeing earlier when we prototyped our Kendo UI Graph.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Debugging Tip&lt;/strong&gt;: If you have your service running, you can copy/paste the result into your javascript to test your UI without having to make the service calls&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1055.image_5F00_79D5C5B2.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/2548.image_5F00_thumb_5F00_0088CF36.png" width="459" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;&lt;/blockquote&gt;

&lt;h1&gt;&lt;strong&gt;Getting Specific Reports&lt;/strong&gt;&lt;/h1&gt;

&lt;p&gt;With the basic WebAPI infrastructure in place, let’s start creating some reports. Reports tend to come in groups. For instance, the manager of Amazing Pie wants to evaluate the effectiveness of seating at various locations. Based on the number of seats at the Bar, Lounge, Dining Room, how often are they filled? Should they possibly expand one area, and reduce another? The manager may look at one or many locations. He may look for trends by month or day of the week. Another report may evaluate the menu and which items are selling. To group the various reports, we’ll create one WebAPI &lt;a href="http://msdn.microsoft.com/en-us/library/hh834453(v=vs.108).aspx"&gt;APIController&lt;/a&gt; class for each type of report.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Modify the Seating Report Controller&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;This is where we’re going to capture the total number of seats for each location. Using LINQ, we’re going to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Query the Tables entity&lt;/li&gt;

  &lt;li&gt;Filter by the Location passed in&lt;/li&gt;

  &lt;li&gt;Group by the TableType&lt;/li&gt;

  &lt;li&gt;Get a Sum of the TableSize for each TableType at each Location&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1. &lt;strong&gt;Open the&lt;/strong&gt; &lt;strong&gt;SeatingController &lt;/strong&gt;from the Server\Reports folder&lt;/p&gt;

&lt;p&gt;2. Add the Extension Methods for query operators&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;b&gt;&lt;i&gt;Note&lt;/i&gt;&lt;/b&gt;&lt;i&gt;: this is an important step. Without these extension methods, the LINQ query operators will not be available on the DataWorkspace&lt;/i&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;&lt;hr /&gt;VB
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;span style="background: white; color: blue;"&gt;Option Infer On
Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Net
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;System.Web.Http
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Microsoft.LightSwitch
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Imports &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;LightSwitchApplication
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI" size="2"&gt;C#
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Microsoft.LightSwitch;
&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;ol&gt;&lt;/ol&gt;

&lt;p&gt;3. Remove the additional overloads for Get, Put, Post and Delete methods as we’re only using this ApiController for Getting reports.&lt;/p&gt;

&lt;p&gt;4. Change the parameter from int to string in the method we edited earlier 
  &lt;br /&gt;&lt;em&gt;The Location_Id from the Table entity in our AmazingPie datamodel is of type string&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;5. Add the following LINQ query&lt;/p&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;strong&gt;&lt;font face="Segoe UI"&gt;&lt;hr /&gt;VB
&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Public Function &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;[Get](id &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As String&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;) &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As Object
    Using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;As &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;= &lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;.CreateContext()
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;span style="background: white; color: blue;"&gt;        Dim &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult =
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;From &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;t &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;In &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;context.DataWorkspace.AmazingPieData.Tables
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Where &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;t.Location.Location_Id = id
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Group By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;t.TableType.TableType_Id, t.TableType.DisplayOrder &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Into Group
            Order By &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;DisplayOrder
            &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Select &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;TableType_Id, Seats = Group.Sum(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Function&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(t) t.TableSize)
&lt;br /&gt;&lt;/span&gt;        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;Return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult.Execute()
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;End Using
End Function
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Segoe UI"&gt;&lt;strong&gt;C#
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;public object &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;Get(&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;string &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;id) {
    &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;using &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;(ServerApplicationContext context = ServerApplicationContext.CreateContext()) {
        var reportResult = context.DataWorkspace.AmazingPieData.Tables
            .Where(t =&amp;gt; t.Location.Location_Id == id)
            .GroupBy(g =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                g.TableType.TableType_Id
            })
            .Select(g =&amp;gt; &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;{
                TableType_ID = g.Key.TableType_Id.Trim(),
                Seats = g.Sum(t =&amp;gt; t.TableSize)
            });
        &lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;return &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportResult.Execute();
    }
}
&lt;hr /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h2&gt;Evaluating the LINQ query&lt;/h2&gt;

&lt;p&gt;To understand how the LINQ query is working here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We instance the context inside a using block to assure the ServerApplicationContext is disposed. &lt;/li&gt;

  &lt;li&gt;Using the typed context, we can access the DataWorkspace, and drill into the AmazingPieData entity and the Tables collection.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Remember, Tables is the name of our SQL Table that contains the list of tables in the restaurant. It’s not the collection of SQL Tables.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;We pass the id parameter to filter Restaurant Tables by the Location_Id&lt;/li&gt;

  &lt;li&gt;In order to get a grouping of the subset of properties, we need to create an anonymous type, and create the collection into g. The LINQ query will pass the query to the database, where the group by will be performed inside the database, avoiding all the data streaming to the middle tier for aggregation.&lt;/li&gt;

  &lt;li&gt;By adding the DisplayOrder to the group by, we can use the TableType.DisplayOrder property to sort our TableTypes by a logical order&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Order By Tip:&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; I wanted to sort the graph by Bar, Lounge, Dining. Sorting by TableType would have created Bar, Lounge, Dining. The Lookup table for TableType contains the DisplayOrder for just this purpose. This is a common practice to assure your lists are displayed in a logical sequence such as (OrdrePlaced, OnHold, Picking, Shipped, Returned)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;With the GroupBy, we reduce the quantity of rows, with the anonymous return type, we reduce the quantity of columns&lt;/li&gt;

  &lt;li&gt;Since LINQ queries defer their execution until they’re requested, which is when the WebAPI stack kicks in, outside of the Get(string id) method, we must call execute here to use the ServerApplicationContext before it’s disposed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;&lt;strong&gt;Reducing the resultset&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;With the above query, we’re returning just 3 rows, and two properties. Dramatically smaller than returning all the rows and attempting to summarize this on the client.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: white; color: black;"&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;[{ &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Bar&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: 21 },
 { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Lounge&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: 23 },
 { &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;TableType_Id&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Dining&amp;quot;&lt;/span&gt;&lt;span style="background: white; color: black;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;Seats&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: black;"&gt;&lt;font face="Consolas" size="2"&gt;: 48 }]&lt;/font&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In the case of AmazingPie, the largest quantity of tables is 'BelSquare' which has 32 tables. However, when we start aggregating the number of guests for a given restaurant, we may be processing hundreds of thousands of records. Yet, we only need to display a dozen values. Using LINQ, the new LightSwitch Aggregates such as GroupBy, WebAPI and JSON we can leverage the processing power of each tier of the application, minimize the data sent across the internet and still provide rich visuals to our end users.&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;Testing our Report WebAPI&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;With the code in place, we’ll first evaluate the results with Fiddler. Unit testing makes it easy to dissect the data before we start connecting the HTML client with javascript.&lt;/p&gt;

&lt;p&gt;1. Build your app, or launch it with F5&amp;#160;&amp;#160; &lt;/p&gt;

&lt;p&gt;2. In Fiddler, remembering your base URL, compose the request. 
  &lt;br /&gt;Here’s a visual mapping of what we’ve done so far: 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6087.image_5F00_43875788.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4747.image_5F00_thumb_5F00_330EE68D.png" width="811" height="868" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Connecting our HTML Client Graph to the WebAPI Report&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;With our WebAPI written and tested, we can now replace our SampleData with the WebAPI call&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We’ll first need a variable to contain our URL we’ll utilize for our WebAPI Reports call&lt;/li&gt;

  &lt;li&gt;We’ll then update the KendoChart to use WebAPI/JSON to retrieve the data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1. Rather than switch back to logical view, we can stay in the File view to open our Location_View.js which is located under the UserCode folder.&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0045.OpenLocation_5F00_Viewjs_5F00_00AB130E.png"&gt;&lt;img title="OpenLocation_Viewjs" style="display: inline; background-image: none;" border="0" alt="OpenLocation_Viewjs" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4331.OpenLocation_5F00_Viewjs_5F00_thumb_5F00_2779294E.png" width="274" height="307" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;2. Create the reportsAPI variable. It should look similar to this when complete: 
  &lt;br /&gt;&lt;a href="http://localhost:22700/reports/Seating/SeaBallard"&gt;http://localhost:22700/reports/Seating/SeaBallard&lt;/a&gt; 

  &lt;br /&gt;We’ll construct the url using the relative path, passing in the reports API path, report class name and the parameter based on the contentItem parameter passed into the SeatedGuests_render function.&lt;/p&gt;

&lt;p&gt;3. Below the point where we append the locationSeatingChartContainer, add the following code.&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;, the existing code is greyed for clarity&lt;/em&gt;&lt;/em&gt;&amp;#160;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;hr /&gt;&lt;font size="2"&gt;&lt;span&gt;// Create a &amp;lt;div&amp;gt; to contain our chart
&lt;/span&gt;var &lt;span&gt;locationSeatingChartContainer = $(&lt;/span&gt;&lt;span&gt;'&amp;lt;div id=&amp;quot;chartContainer&amp;quot; class=&amp;quot;chart-wrapper&amp;quot;  style=&amp;quot;width:600px&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span&gt;;
locationSeatingChartContainer.appendTo($(element));&lt;/span&gt;

&lt;font color="#666666"&gt;&lt;/font&gt;&lt;span style="background: white; color: green;"&gt;// http://localhost:22700/reports/Seating/SeaBallard
&lt;/span&gt;&lt;span style="background: white; color: blue;"&gt;var &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;reportsAPI = &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;../reports/Seating/&amp;quot; &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;+ contentItem.screen.Location.Location_Id;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&amp;#160; &lt;hr /&gt;&lt;/pre&gt;

&lt;p&gt;4. We can now comment out the &lt;strong&gt;data:&lt;/strong&gt; attribute used for our sample data, and provide the &lt;strong&gt;transport:&lt;/strong&gt;attribute which will fetch the data from the WebAP, using the reportsAPI URL.&amp;#160;&amp;#160; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span&gt;&lt;hr /&gt;&lt;font face="Consolas" size="2"&gt;// Create a &amp;lt;div&amp;gt; to contain our chart
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span&gt;var &lt;/span&gt;&lt;span&gt;locationSeatingChartContainer = $(&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;'&amp;lt;div id=&amp;quot;chartContainer&amp;quot; class=&amp;quot;chart-wrapper&amp;quot;  style=&amp;quot;width:600px&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span&gt;);
locationSeatingChartContainer.appendTo($(element));
 
&lt;/span&gt;&lt;span&gt;// http://localhost:22700/reports/Seating/SeaBallard
&lt;/span&gt;&lt;span&gt;var &lt;/span&gt;&lt;span&gt;reportsAPI = &lt;/span&gt;&lt;span&gt;&amp;quot;../reports/Seating/&amp;quot; &lt;/span&gt;&lt;span&gt;+ contentItem.screen.Location.Location_Id;
 
locationSeatingChartContainer.kendoChart({
    &lt;/span&gt;&lt;span&gt;// set the theme
    &lt;/span&gt;&lt;span&gt;theme: $(document).data(&lt;/span&gt;&lt;span&gt;&amp;quot;kendoSkin&amp;quot;&lt;/span&gt;&lt;span&gt;) || &lt;/span&gt;&lt;span&gt;&amp;quot;black&amp;quot;&lt;/span&gt;&lt;span&gt;,
    &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;// set the datasource to use our WebAPI reports controller
    &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;dataSource: {
        &lt;/span&gt;&lt;span style="background: white; color: green;"&gt;//data: sampleData,
        &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;transport: {
            read: {
                url: reportsAPI,
                dataType: &lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&amp;quot;json&amp;quot;
            &lt;/span&gt;&lt;span style="background: white; color: black;"&gt;}
        }
    },
    title: {
        text: &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="background: white; color: rgb(163, 21, 21);"&gt;&lt;font face="Consolas" size="2"&gt;&amp;quot;Seats Per Location&amp;quot;&lt;/font&gt;
&lt;hr /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;5. Run the app and see the results 
  &lt;br /&gt;The Details Page for BelSquare&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/7120.image_5F00_07F84927.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1856.image_5F00_thumb_5F00_0EAB52AA.png" width="615" height="493" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the Graph of the tables for BelSquare&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/1778.clip_5F00_image001_5F00_599EC379.png"&gt;&lt;img title="clip_image001" style="display: inline; background-image: none;" border="0" alt="clip_image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5164.clip_5F00_image001_5F00_thumb_5F00_006CD9BA.png" width="640" height="538" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;&lt;strong&gt;Wrapping it up&lt;/strong&gt;&lt;/h1&gt;

&lt;p&gt;Whew. That was a lot. I did take some extra time to explain some of the nuances and troubleshooting techniques, which hopefully you’ll find valuable as these were the things I tripped over and will hopefully spare you some pain.&lt;/p&gt;

&lt;p&gt;Using LightSwitch, WebAPI and the new ServerApplicaitonContext we were able to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Expose a WebAPI JSON Payload&lt;/li&gt;

  &lt;li&gt;Write LINQ queries to aggregate results, processed on the data tier, returning just the data we need to display&lt;/li&gt;

  &lt;li&gt;Provide fast, read-only data useful for graphs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;Steve Lasker 
  &lt;br /&gt;Microsoft Program Manager 

  &lt;br /&gt;Visual Studio LightSwitch&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/SteveLasker"&gt;http://blogs.msdn.com/SteveLasker&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10411722" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/How_2D00_To/">How-To</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/LightSwitch/">LightSwitch</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/HTML/">HTML</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Data/">Data</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/API/">API</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/WebAPI/">WebAPI</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Steve+Lasker/">Steve Lasker</category></item><item><title>Using the LightSwitch ServerApplicationContext API (Matt Evans)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2013/04/15/using-serverapplicationcontext.aspx</link><pubDate>Mon, 15 Apr 2013 18:44:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10411207</guid><dc:creator>LightSwitch Team</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/lightswitch/rsscomments.aspx?WeblogPostID=10411207</wfw:commentRss><comments>http://blogs.msdn.com/b/lightswitch/archive/2013/04/15/using-serverapplicationcontext.aspx#comments</comments><description>&lt;p&gt;The ServerApplicationContext API is a new feature in LightSwitch, available with Visual Studio 2012 Update 2 or later, which allows you to create entirely new ways to call custom business logic on the LightSwitch Server, using the same rich API you're used to working with on the server tier. &lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2012/11/19/a-new-api-for-lightswitch-server-interaction-the-serverapplicationcontext.aspx"&gt;We previewed this API&lt;/a&gt; in the VS 2012 HTML Client Preview 2 release, but we've made a few tweaks since then, and this article discusses the API in a bit more depth. &lt;/p&gt;  &lt;h3&gt;Background &lt;/h3&gt;  &lt;p&gt;By default, the only way a client or service can communicate with the LightSwitch server is via the OData protocol, and only to EntitySets and Queries you've created in the Query designer. See &lt;a href="http://msdn.microsoft.com/en-us/library/hh973174.aspx"&gt;&lt;em&gt;LightSwitch as a Data Source&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt; &lt;/p&gt;  &lt;p&gt;We recently introduced a feature in the LightSwitch server which allows developers to create alternative entry points on the LightSwitch middle tier (a.k.a. the server). This is very handy if you want the server to communicate with clients that don't understand OData, or you need to return data that isn't shaped like one of your Entities. For instance, if you want to invoke some custom logic on the server, the solution until now has been the &lt;a href="http://blog.pragmaswitch.com/?p=332"&gt;&amp;quot;command table&amp;quot; pattern&lt;/a&gt;, where you create an entity which is just a conduit for sending work requests to the server. Another common request we get is for a way to generate reports and interactive dashboards. Reports usually aren't shaped like whole entities, but rather projections of entities and aggregates. To solve this sort of reporting problem, people have had to resort to cumbersome mechanisms like custom RIA services in order to be able to transfer non-entity data out of the server.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Eventually it would be nice to have a great inbox experience for reporting and for service operations. However, in the interim, we have introduced the ability for developers to use the LightSwitch API inside of their own web service endpoints. You can add any of the normal ASP.NET web assets to your Server project and create new ways of interacting with the LightSwitch server. You could create something quick and dirty like an ASP.NET Web Form, or something more powerful like a WCF Service or a Web API endpoint. The key point is that you decide the appropriate way you'd like to expose a new service, using the normal Visual Studio gestures for adding and working with those assets. &lt;/p&gt;  &lt;p&gt;Technically, it has always been possible to add aspx pages and Web API calls to the LightSwitch server, but there was no easy way for you to use the LightSwitch API inside your custom entry points, so it wasn't a great experience. &lt;/p&gt;  &lt;p&gt;With the ServerApplicationContext API, we've made certain scenarios much easier, and we're opening things up to your imagination. &lt;/p&gt;  &lt;h3&gt;A quick and dirty example &lt;/h3&gt;  &lt;p&gt;1. Create a new LightSwitch HTML / C# Application    &lt;br /&gt;2. Add a new Table, called &amp;quot;Customer&amp;quot;. Give it two properties, &amp;quot;Name&amp;quot; and &amp;quot;BirthDate&amp;quot;     &lt;br /&gt;3. Add a new Browse Screen for the Customer Table     &lt;br /&gt;4. In Solution Explorer, change to &amp;quot;File View&amp;quot; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5758.image_5F00_2EF46BB4.png"&gt;&lt;img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/5342.image_5F00_thumb_5F00_35A77537.png" width="420" height="238" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;5. Select the Server project in Solution Explorer    &lt;br /&gt;6. Right click on the Server Project, choose &amp;quot;Add&amp;quot; and then choose &amp;quot;New Item&amp;quot; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/6835.image_5F00_0E6D2C02.png"&gt;&lt;img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/8463.image_5F00_thumb_5F00_6732E2CC.png" width="581" height="520" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;7. Search for &amp;quot;web form&amp;quot;    &lt;br /&gt;8. Add a new asp.net web form named &amp;quot;MakeData.aspx&amp;quot; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/4370.image_5F00_46E23AA4.png"&gt;&lt;img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-73-metablogapi/0257.image_5F00_thumb_5F00_147E6725.png" width="694" height="389" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;9. Expand MakeData.aspx in the Solution explorer. Double click on the code-behind file (MakeData.aspx.cs)    &lt;br /&gt;10. Paste the following code into the Page_Load method:     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;font color="#424242" face="Segoe UI"&gt;C# Code:&lt;/font&gt;       &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;protected&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;void&lt;span style="color: black;"&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;span style="color: black;"&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;span style="color: black;"&gt; e)                      &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; context = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext())                  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;span style="color: black;"&gt; c = context.DataWorkspace.ApplicationData.Customers.AddNew();          &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; c.Name = &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;Good Guy Greg&amp;quot;&lt;span style="color: black;"&gt;;          &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; c.BirthDate = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;span style="color: black;"&gt;.Today;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;context.DataWorkspace.ApplicationData.SaveChanges();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt;"&gt;&lt;span style="background-color: white;"&gt;}&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/span&gt;    &lt;br /&gt;VB Code – note that you'll want to add &amp;quot;Imports LightSwitchApplication&amp;quot; at the top of your VB code files     &lt;br /&gt;    &lt;br /&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Protected&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;span style="color: black;"&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;span style="color: black;"&gt; sender &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Object&lt;span style="color: black;"&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;span style="color: black;"&gt; e &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; System.&lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;span style="color: black;"&gt;) &lt;span style="color: blue;"&gt;Handles&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Me&lt;span style="color: black;"&gt;.Load                                              &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; Context &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;span style="color: black;"&gt; = Context.DataWorkspace.ApplicationData.Customers.AddNew()&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;c.Name = &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;Good Guy Greg&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;c.BirthDate = &lt;span style="color: blue;"&gt;Date&lt;span style="color: black;"&gt;.Today&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;Context.DataWorkspace.ApplicationData.SaveChanges()&amp;#160; &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt; End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;11. Make another web form called &amp;quot;ShowData.aspx&amp;quot;. Add a using statement for &amp;quot;Microsoft.LightSwitch&amp;quot;.   &lt;br /&gt;12. Put the following code into the Page_Load method &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;C# Code: &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;protected&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;void&lt;span style="color: black;"&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;span style="color: black;"&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;span style="color: black;"&gt; e)                      &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; context = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext())                  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;foreach&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;in&lt;span style="color: black;"&gt; context.DataWorkspace.ApplicationData.Customers)                  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;Response.Write(c.Id + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot; &amp;quot;&lt;span style="color: black;"&gt; + c.Name + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot; &amp;quot;&lt;span style="color: black;"&gt; + c.BirthDate + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;br&amp;gt;\r\n&amp;quot;&lt;span style="color: black;"&gt;);                  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}&lt;/span&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;VB Code:    &lt;br /&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: blue;"&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Protected&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;span style="color: black;"&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;span style="color: black;"&gt; sender &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Object&lt;span style="color: black;"&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;span style="color: black;"&gt; e &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; System.&lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;span style="color: black;"&gt;) &lt;span style="color: blue;"&gt;Handles&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Me&lt;span style="color: black;"&gt;.Load                                            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; Context &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: blue;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;         &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; For Each c As &lt;span style="color: rgb(43, 145, 175);"&gt;Customer &lt;span style="color: blue;"&gt;In &lt;font color="#000000"&gt;Context.DataWorkspace.ApplicationData.Customers&lt;/font&gt;             &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.Write(c.Id.ToString() + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot; &amp;quot; &lt;font color="#000000"&gt;+ c.Name +&lt;/font&gt; &amp;quot; &amp;quot; &lt;font color="#000000"&gt;+ c.BirthDate +&lt;/font&gt; &amp;quot;&amp;lt;br&amp;gt;&amp;quot; &lt;font color="#000000"&gt;+ vbCrLf&lt;/font&gt;)         &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Next        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: blue;"&gt;End Using        &lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: blue;"&gt;End Sub&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;   &lt;p&gt;13. F5 your application    &lt;br /&gt;14. Note the URI of the app during F5; it should be something like &lt;a href="http://localhost:12345/htmlclient/"&gt;http://localhost:12345/htmlclient/&lt;/a&gt;     &lt;br /&gt;15. Open a new browser tab, and manually type in the following uri: &lt;a href="http://localhost:12345/MakeData.aspx"&gt;http://localhost:12345/MakeData.aspx&lt;/a&gt; Fix up the port number, as needed.     &lt;br /&gt;16. Open a new browser tab, and manually type in the following uri: &lt;a href="http://localhost:12345/ShowData.aspx"&gt;http://localhost:12345/ShowData.aspx&lt;/a&gt;     &lt;br /&gt;17. Go back to the original tab, which shows the HTML client. Refresh this tab. You should see new data in your app. &lt;/p&gt;  &lt;p&gt;If all went well, you should have seen your entity data in steps 15, formatted as uninteresting text, and again in step 16, inside the HTML client UI. &lt;/p&gt;  &lt;p&gt;This example isn't especially interesting, but shows that if you know ASP.NET development, you can now build arbitrary pages and other types of endpoints that read and write to your LightSwitch data, using the LightSwitch API. &lt;/p&gt;  &lt;h3&gt;API Overview &lt;/h3&gt;  &lt;p&gt;There are actually two primary ServerApplicationContext classes. One of them is strongly typed for your application, that is, it understands which data sources, entities, and queries are in your specific LightSwitch project. This is what you'll use most of the time. It lets you write code like this: &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;C# Code: &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; context = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext())                  &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{&amp;#160; &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;span style="color: black;"&gt; v = &lt;span style="color: blue;"&gt;from&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;in&lt;span style="color: black;"&gt; context.DataWorkspace.ApplicationData.Customers                  &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; where&lt;span style="color: black;"&gt; c.Name.Contains(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;Matt&amp;quot;&lt;span style="color: black;"&gt;)              &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;select&lt;span style="color: black;"&gt; c; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&lt;font color="#424242" face="Segoe UI"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;foreach&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;in&lt;span style="color: black;"&gt; v) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;Response.Write(c.Name + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;br&amp;gt;\r\n&amp;quot;&lt;span style="color: black;"&gt;);          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;VB Code &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; Context &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; Dim&lt;span style="color: black;"&gt; v = &lt;span style="color: blue;"&gt;From&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;In&lt;span style="color: black;"&gt; Context.DataWorkspace.ApplicationData.Customers                  &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Where&lt;span style="color: black;"&gt; c.Name.Contains(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;Matt&amp;quot;&lt;span style="color: black;"&gt;)              &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Select&lt;span style="color: black;"&gt; c &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;For&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Each&lt;span style="color: black;"&gt; c &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;In&lt;span style="color: black;"&gt; v                          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;Response.Write(c.Name + &lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;span style="color: black;"&gt; + vbCrLf)&amp;#160; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; Next       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;Note that because we are using the strongly typed model, our context has knowledge of the ApplicationData service and its Customers table, and all of the properties on the Customer entity. &lt;/p&gt;  &lt;h3&gt;Weakly Typed ServerApplicationContext &lt;/h3&gt;  &lt;p&gt;There is another ServerApplicationContext class which is weakly typed. It has no compile time knowledge of your entities or other project assets. However, it can access these items at runtime, using the Weakly Typed API. (Read more &lt;a href="http://blogs.msdn.com/b/mattev/archive/2010/10/11/introduction-to-the-lightswitch-weakly-typed-api.aspx"&gt;here&lt;/a&gt;). The weakly typed ServerApplicationContext is actually created by a call to the ServerApplicationContextFactory: &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;C# Code &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;IServerApplicationContext&lt;span style="color: black;"&gt; icontext = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContextFactory&lt;span style="color: black;"&gt;.CreateContext())                  &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;span style="color: black;"&gt; typ = icontext.DataWorkspace.SecurityData.GetAuthenticationType();         &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; if&lt;span style="color: black;"&gt; (typ.HasFlag(&lt;span style="color: rgb(43, 145, 175);"&gt;AuthenticationType&lt;span style="color: black;"&gt;.Windows) || typ.HasFlag(&lt;span style="color: rgb(43, 145, 175);"&gt;AuthenticationType&lt;span style="color: black;"&gt;.Forms))                  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;{ &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;i++;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;}&lt;/span&gt; &lt;/p&gt;  &lt;p&gt;VB Code – note you'll need to add &amp;quot;Imports Microsoft.LightSwitch.Server&amp;quot; and &amp;quot;Imports Microsoft.LightSwitch.Security&amp;quot; at the top of your source file.. &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; icontext &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContextFactory&lt;span style="color: black;"&gt;.CreateContext()                      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;span style="color: black;"&gt; typ = icontext.DataWorkspace.SecurityData.GetAuthenticationType()          &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;&amp;#160;&amp;#160;&amp;#160; If&lt;span style="color: black;"&gt; (typ.HasFlag(&lt;span style="color: rgb(43, 145, 175);"&gt;AuthenticationType&lt;span style="color: black;"&gt;.Windows) &lt;span style="color: blue;"&gt;Or&lt;span style="color: black;"&gt; typ.HasFlag(&lt;span style="color: rgb(43, 145, 175);"&gt;AuthenticationType&lt;span style="color: black;"&gt;.Forms)) &lt;span style="color: blue;"&gt;Then&lt;span style="color: black;"&gt;                          &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i = i + 1      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;If           &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;Suppose that you are writing some sort of extension module that enables generic reporting or import/export scenarios. You want to create a package that anyone can add to their LightSwitch application which will create new Web API endpoints that allow for exporting data as csv files. Because your module needs to work with any possible LightSwitch application, it has no strongly typed model to work with. However, it is straightforward to write weakly typed code which will enumerate the datasources, entitysets, key properties, and so on, allowing you to create a generic module that can operate in &lt;em&gt;any&lt;/em&gt; LightSwitch application. The dynamic URL parsing and routing of Web API makes this an especially interesting scenario, e.g. suppose someone requests the following uri: &lt;/p&gt;  &lt;p&gt;http://contoso.com/myLightSwitchApp/CsvExporter/Customers &lt;/p&gt;  &lt;p&gt;It would be straightforward to write a generic module which implemented this CSV exporter as a Web API endpoint (CsvExporter), which would infer the EntitySet (Customers) to export based on the incoming URI. &lt;/p&gt;  &lt;p&gt;As a side note, because the SecurityData data service is available in any LightSwitch application, that dataservice will be available strongly typed even on a weakly typed ServerApplicationContext, as seen in the example above. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Challenge&lt;/strong&gt;: After you've completely read this article, take another look at the above example where I call ServerApplicationContextFactory.CreateContext. Will the variable &lt;strong&gt;&lt;em&gt;i&lt;/em&gt;&lt;/strong&gt; ever get incremented by this code? Why or why not? &lt;/p&gt;  &lt;h3&gt;Current vs. CreateContext &lt;/h3&gt;  &lt;p&gt;There are two items of interest on the ServerApplicationContext classes: the &lt;strong&gt;&lt;em&gt;Current&lt;/em&gt;&lt;/strong&gt; property and the &lt;strong&gt;&lt;em&gt;CreateContext&lt;/em&gt;&lt;/strong&gt; method. The &lt;em&gt;Current&lt;/em&gt; property returns the currently in-scope ServerApplicationContext, if one exists. The &lt;em&gt;CreateContext&lt;/em&gt; method creates a new ServerApplicationContext for your use. &lt;/p&gt;  &lt;p&gt;Unlike &lt;a href="http://msdn.microsoft.com/en-us/library/vstudio/gg445195.aspx"&gt;DataWorkspaces&lt;/a&gt;, which can be &amp;quot;Stacked&amp;quot; so that many are simultaneously in scope, only one ServerApplicationContext can be present for a given logical request on the server. Each incoming request to one of the in-built LightSwitch server endpoints has its own ServerApplicationContext automatically created for the lifetime of the request, and which is used to service all activity for that request. If you were to try to create a second ServerApplicationContext when one was already present, you would get a &lt;em&gt;ContextExistsException&lt;/em&gt;&lt;span style="text-decoration: underline;"&gt;. &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;When you are creating your own entry points into the server, it is typically safe to simply call &lt;em&gt;CreateContext&lt;/em&gt; without checking to ensure that &lt;em&gt;Current&lt;/em&gt; is null first. This is because the normal LightSwitch server hasn't been called yet; IIS and your code are handling the HTTP request routing and LightSwitch hasn't had the opportunity to initialize anything on your behalf. &lt;/p&gt;  &lt;p&gt;On the other hand, if you are inside of normal LightSwitch code on the server, like SaveChanges_Executing or Customer_Inserting, attempting to create a new ServerApplicationContext will always fail, because in these cases, the ServerApplicationContext that the LightSwitch save pipeline has created for its own use will already exist. &lt;/p&gt;  &lt;p&gt;In almost all cases where you are defining the web entry point yourself (a webform, Web API, etc), to use a ServerApplicationContext you just do this: &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;C# Code &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; context = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext()) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt; { &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: green;"&gt;// my code goes here&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt; } &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;VB Code:&lt;/span&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; Context &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: green;"&gt;' my code goes here&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;Authentication &lt;/h3&gt;  &lt;p&gt;Because the key usage scenarios for ServerApplicationContext involve creating new service endpoints on the LightSwitch server, by default, if your LightSwitch application is set to use authentication, ServerApplicationContext tries to enforce user authentication. Specifically, if in your web.config, the Authentication mode is Windows or Forms, when your code tries to create a new ServerApplicationContext by calling CreateContext, if there isn't a valid authenticated user already on the HttpContext, your call to CreateContext will throw an exception. &lt;/p&gt;  &lt;p&gt;If you know what you are doing and do not want this behavior, you can tell CreateContext to skip the authentication check, by calling it in the following way: &lt;/p&gt;  &lt;p&gt;C# Code &lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue; font-family: consolas; font-size: 9pt;"&gt;&lt;span style="background-color: white;"&gt;using&lt;span style="color: black;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; context = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext(&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContextCreationOptions&lt;span style="color: black;"&gt;.SkipAuthentication))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;VB Code &lt;/p&gt;  &lt;p&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;Using&lt;span style="color: black;"&gt; Context &lt;span style="color: blue;"&gt;As&lt;span style="color: black;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt; = &lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContext&lt;span style="color: black;"&gt;.CreateContext(&lt;span style="color: rgb(43, 145, 175);"&gt;ServerApplicationContextCreationOptions&lt;span style="color: black;"&gt;.SkipAuthentication)                          &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: green;"&gt;' allow in unauthenticated users       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: green;"&gt;' my code goes here       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: consolas; font-size: 9pt; background-color: white;"&gt;&lt;span style="color: blue;"&gt;End&lt;span style="color: black;"&gt; &lt;span style="color: blue;"&gt;Using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;The SkipAuthentication flag tells CreateContext not to do the authentication check. &lt;/p&gt;  &lt;h3&gt;Next Steps &lt;/h3&gt;  &lt;p&gt;There are some more complete end to end examples that use ServerApplicationContext, which you can read about here: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/lightswitch/archive/2012/11/19/a-new-api-for-lightswitch-server-interaction-the-serverapplicationcontext.aspx"&gt;A New API for LightSwitch Server Interaction: The ServerApplicationContext&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/171/Creating-ASP-NET-Web-Forms-CRUD-Pages-Using-ServerApplicationContext.aspx"&gt;Creating ASP.NET Web Forms CRUD Pages Using ServerApplicationContext&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Note that these were written in the HTML Preview 2 timeframe, and so the location of the ServerApplicationContext classes is a little bit different. We've got more blog posts planned with some good reporting examples so stay tuned! &lt;/p&gt;  &lt;p&gt;- Matt Evans, Tester, LightSwitch Team&lt;/p&gt;  &lt;ul&gt;&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10411207" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Matt+Evans/">Matt Evans</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Code/">Code</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/API/">API</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/Server/">Server</category><category domain="http://blogs.msdn.com/b/lightswitch/archive/tags/WebAPI/">WebAPI</category></item></channel></rss>