<?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>New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx</link><description>Following the recent announcement of the LightSwitch HTML Client Preview 2 , we are excited to introduce a set of additional APIs that allow further control over the behavior and capabilities of a LightSwitch HTML-based application. You can download Preview</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10405155</link><pubDate>Mon, 25 Mar 2013 16:29:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10405155</guid><dc:creator>Stephen Provine [MSFT]</dc:creator><description>&lt;p&gt;Rama,&lt;/p&gt;
&lt;p&gt;Ok, I think I understand your problem now. Just to confirm, you are querying to get orders and expanding to include customers, since that is the only way reading from traditional OData services to get customer information for each order. When you are importing the orders, you want to associate each order with the customer that was also queried.&lt;/p&gt;
&lt;p&gt;This scenario is not currently well supported in LightSwitch. The ideal way you would do this is to directly set the foreign key value on the imported order, like this:&lt;/p&gt;
&lt;p&gt;importedOrder.CustomerID = results[i].Customer.CustomerID;&lt;/p&gt;
&lt;p&gt;Then importedOrder.Customer would automatically be loaded by LightSwitch based on the CustomerID. However, this is not possible because we are not exposing foreign keys. You tried this:&lt;/p&gt;
&lt;p&gt;importedOrder.Customer = results[i].Customer;&lt;/p&gt;
&lt;p&gt;But this does not work because the object expected to be returned by importedOrder.Customer is a LightSwitch Customer object, not a raw object containing data returned by an OData query.&lt;/p&gt;
&lt;p&gt;The only way you can make this work today is if you manually query the LightSwitch service for each Customer based on the ID you read from the query, and then after retrieving that data, assign the actual entity value. For each imported order, you could call a function like this:&lt;/p&gt;
&lt;p&gt;function setCustomerByID(importedOrder, customerID) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;myapp.activeDataWorkspace.NorthwindData.Customers&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.Customers_SingleOrDefault(results[i].Customer.CustomerID).execute().then(function (results) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;importedOrder.Customer = results.results[0];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;});&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;In practice, if you are bulk importing a lot of orders, you would want to optimize this so that you don&amp;#39;t keep querying for the same customer many times. Therefore you might start by first maintaining a mapping of customerIDs to imported orders (create an object whose keys are the customerID values and whose values are arrays of imported order objects). Then after importing all the orders, iterate through the keys on the object, run the above query once for that customer ID, then set the same customer on all the imported orders in the associated array.&lt;/p&gt;
&lt;p&gt;Sorry there is not an easier way right now to do this. Hope this information helps. And please post these kinds of questions in the future in the LightSwitch forums - it is easier to manage these kinds of questions there.&lt;/p&gt;
&lt;p&gt;Stephen&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10405155" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10404783</link><pubDate>Sat, 23 Mar 2013 11:35:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10404783</guid><dc:creator>Dwarapudi</dc:creator><description>&lt;p&gt;Hi Stephen.&lt;/p&gt;
&lt;p&gt;I am importing only Orders. In orders It contains OrderID, OrderDate and CustomerID etc. &amp;nbsp;I am getting Id &amp;nbsp;But unable to read the name from Customers Table.&lt;/p&gt;
&lt;p&gt; Please let me know if it is not clear so that I can send you the sample screen shots? please mail me your email address to dwarapudi@live.in&lt;/p&gt;
&lt;p&gt;Thank You,&lt;/p&gt;
&lt;p&gt;Rama &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10404783" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10403724</link><pubDate>Tue, 19 Mar 2013 23:17:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10403724</guid><dc:creator>Stephen Provine [MSFT]</dc:creator><description>&lt;p&gt;Hi Dwarapudi,&lt;/p&gt;
&lt;p&gt;One last question - as part of the import operation, are you importing both orders AND employees, or only orders (and you want to select existing employees for each order)?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Stephen&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10403724" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10402989</link><pubDate>Sun, 17 Mar 2013 12:30:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10402989</guid><dc:creator>Dwarapudi</dc:creator><description>&lt;p&gt;Hi Stephen,&lt;/p&gt;
&lt;p&gt;Thank you for your response. The question is how to get a value from the other table and inserting into the linked table.&lt;/p&gt;
&lt;p&gt;E.g : I have two tables, one is Orders and Second one is Customers. &amp;nbsp;When creating an order I want to add few of the customers based on filter condition.&lt;/p&gt;
&lt;p&gt;Orders&lt;/p&gt;
&lt;p&gt;---------------&lt;/p&gt;
&lt;p&gt;OrderDate &lt;/p&gt;
&lt;p&gt;Customer - FK&lt;/p&gt;
&lt;p&gt;Customers &lt;/p&gt;
&lt;p&gt;-------------------&lt;/p&gt;
&lt;p&gt;Customer ID - PK&lt;/p&gt;
&lt;p&gt;CustomerName &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am using your sample code &amp;nbsp;by showing CustomerName &amp;nbsp;in the screen and inserting the customer Id in to the orders table. How to show the customernames &amp;nbsp;in the screens list. &lt;/p&gt;
&lt;p&gt;===================================&lt;/p&gt;
&lt;p&gt; var results = result.results, importedOrder;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (var i = 0, len = results.length; i &amp;lt; len; i++) {&lt;/p&gt;
&lt;p&gt;importedOrder = screen.Orders.addNew();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// alert(results[i].Name); &amp;nbsp;- Getting Customer Name successfully&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; importedOrder.Customer = results[i].Customer;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p&gt;===================================&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Regards&lt;/p&gt;
&lt;p&gt;Dwarapudi&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10402989" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10401219</link><pubDate>Mon, 11 Mar 2013 16:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10401219</guid><dc:creator>Stephen Provine [MSFT]</dc:creator><description>&lt;p&gt;Hi Dwarapudi,&lt;/p&gt;
&lt;p&gt;Can you be more specific? What value are you getting back from results[i].Employee? I would guess that this value is not valid unless you included an &amp;quot;$expand=Employee&amp;quot; clause in the OData query. See &lt;a rel="nofollow" target="_new" href="http://www.odata.org/documentation/uri-conventions#ExpandSystemQueryOption"&gt;www.odata.org/.../uri-conventions&lt;/a&gt; for more information on this clause.&lt;/p&gt;
&lt;p&gt;If you are still having problems after trying this, please post the question in the forums (&lt;a rel="nofollow" target="_new" href="http://social.msdn.microsoft.com/Forums/en-US/lightswitchhtml"&gt;social.msdn.microsoft.com/.../lightswitchhtml&lt;/a&gt;) instead of as a comment on a blog post.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Stephen&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401219" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10400910</link><pubDate>Sun, 10 Mar 2013 02:23:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10400910</guid><dc:creator>Dwarapudi</dc:creator><description>&lt;p&gt;Hi Stephen, I am having problems when reading one of the list column using the above procedure.&lt;/p&gt;
&lt;p&gt;I have an employee table having relation in order details table.&lt;/p&gt;
&lt;p&gt;importedOrder.Employee = results[i].Employee; &lt;/p&gt;
&lt;p&gt;screen.OrderDetails.selectedItem.Employee = results[i].Employee;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried many ways but can&amp;#39;t figure it out. Could you please help me how to read list column from master table and select it automatically?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Dwarapudi&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400910" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10382137</link><pubDate>Thu, 03 Jan 2013 17:42:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382137</guid><dc:creator>Stephen Provine [MSFT]</dc:creator><description>&lt;p&gt;Christopher, thanks for the feedback. I do recall there were some unfortunate issues with intellisense that were discovered shortly after the release of Preview 2, but I don&amp;#39;t remember there being something in the view model intellisense file. It would be great if you could send me a snippet of the generated code that is incorrect and I&amp;#39;ll take a look.&lt;/p&gt;
&lt;p&gt;As for intellisense not working at all, we have discovered that intellisense can sometimes be intermittent and has to do with the language service caching invalid information. Sometimes it helps to walk the reference chain (the files described by the &amp;lt;reference&amp;gt; tags) and keep trying to get intellisense at the bottom of each referenced file until it starts working. This has the side effect of invalidating these caches and usually gets it working again. If it never works for you, then there is probably something else going on. If you&amp;#39;re able to describe a simple scenario that is broken for you, I can try to reproduce it and get back to you.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382137" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10381208</link><pubDate>Fri, 28 Dec 2012 20:54:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10381208</guid><dc:creator>ChristopherDeMars</dc:creator><description>&lt;p&gt;I&amp;#39;ve experienced a couple of issues with the IntelliSense in the P2 Client:&lt;/p&gt;
&lt;p&gt;1) When I created a &amp;quot;home&amp;quot; screen and added some buttons, that seems to have thrown the IntelliSense file buider for a loop. I dug around and found that in my viewModel.intellisense.js file, several lines of code for my &amp;quot;home&amp;quot; screen were missing commas at the end of the line. That would cause ALL of the intellisense to be broken. I realised that I cuold go into that viewModel.intellisense.js autogenerated file and add the commas and save the file. intellisense would then work - until LightSwitch regenerate the file and break it again. Ugh.&lt;/p&gt;
&lt;p&gt;2) For some other reason that I cannot figure out, intellisense cannot seem to ever work on my entities, regardless of where I&amp;#39;m adding code. I looked through all of the files referenced for intelliSense (&amp;quot;viewModel.js&amp;quot;, &amp;quot;data.js&amp;quot;, &amp;quot;viewModel.intellisense.js&amp;quot;) and none of them have any coding issues (like missing punctuation) so I have no idea where the issue is coming from. When inetellisense pops up, all it says is &amp;quot;IntelliSense was unable to determine an accurate completion list for this for this expression. The provided list contains all identifiers in the file.&amp;quot;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10381208" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10375471</link><pubDate>Fri, 07 Dec 2012 05:24:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10375471</guid><dc:creator>Ben Hayat</dc:creator><description>&lt;p&gt;Thanks Stephen for the reply; Looks like Joe just popped up a new blog that will add more info.&lt;/p&gt;
&lt;p&gt;Very excited about this version coming up.&lt;/p&gt;
&lt;p&gt;..Ben&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10375471" width="1" height="1"&gt;</description></item><item><title>re: New LightSwitch HTML Client APIs (Stephen Provine)</title><link>http://blogs.msdn.com/b/lightswitch/archive/2012/11/13/new-lightswitch-html-client-apis.aspx#10375307</link><pubDate>Thu, 06 Dec 2012 16:56:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10375307</guid><dc:creator>Stephen Provine [MSFT]</dc:creator><description>&lt;p&gt;Ben, that is correct. JS on the client, C# or VB on the server.&lt;/p&gt;
&lt;p&gt;As for third party widgets, we tried to avoid doing anything that would stop you from incorporating these into your application. Take a look back at one of our previous blog posts (&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/b/lightswitch/archive/2012/07/02/writing-javascript-code-in-lightswitch-joe-binder.aspx"&gt;blogs.msdn.com/.../writing-javascript-code-in-lightswitch-joe-binder.aspx&lt;/a&gt;). This is slightly out of date as it targets the first preview, but the concepts and capabilities are the same regarding the render and postRender methods.&lt;/p&gt;
&lt;p&gt;Please let me know if you have any other questions!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10375307" width="1" height="1"&gt;</description></item></channel></rss>