Updating Multiple entities Programmatically in LightSwitch Html Client 2013
hi,
How to Update Multiple entities When Updating One entity in Server Side ?
Thanks in Advance...
You'll probably need to give a little more information about your particular scenario but if you're doing this update server side using the updating method of your entity then you have access to do what you like with any record/entity.
If the entities are related then it may just be a case of a statement like:
YourEntity.YourRelatedEntity.SomeProperty = "Hello world.";
Or you could call a entity specifically from another table and update it accordingly:
AnotherTable ent = DataWorkspace.ApplicationData.AnotherTable.Where(r => r.id == 5).FirstOrDefault();
if (ent != null)
ent.Description = "Hello World.";
Hope that helps you.
Paul.
Similar Messages
-
Hi,
I have this code which is adding a record and re-loading a navigation property "ldDailyLogDetails_FK".
afterClosed:
function (viewScreen, navigationAction) {
if
(navigationAction === msls.NavigateBackAction.commit) {
screen.ldDailyLogDetails_FK.load();
It successfully adds a record and then redisplays this new record on all browsers, but on my phone it adds the record ok, but sometimes, it dosnt seem to refresh (or load) the page with the new record.
I also wonder if there is any place I might go to get some "phone vs desktop browser" information and advice?
I have tried screen.ldDailyLogDetails_FK.refresh(); as well.
davidHi David,
From your description above, it seems that this issue happens occasionally. At the same time you can also use some tool to test your lightswitch application, such as:
Fiddler, it will be helpful to troubleshoot.
Best regards,
Angie
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Lightswitch HTML Client - Detail picker for each related List Item
I have a doubt in Lightswitch Html Client application.
Scenario:
Suppose i have two tables "Property" and "PropertyVaues".
A Property can have many PropertyValues is the relationship between them.
I want to show the data on screen like below:
Property List:
XYZ [___10____(+)]
MNO [___abc____(+)]
PQR [___30.5___(+)]
Xyz is the list item
assume [___10____(+)] is the detail picker of
PropertyValues which allow to select one value related to
XYZ Property item, and same for other list items.
Only Related "PropertyValues" for each list item must be available in the detail picker.
Please help me out if any one has the solution to solve it.
Or you can give me any other way to accomplish the above scenario.
ThanksHello Josh,
I am implementing it on AddEdit screen.
(1)
(2)
Screen description:
[Note: Some Images are in my next post]
1. Image(1) shows the list of properties (GSM, Mill Name, CMS). These Properties have its respective property values in drop down.
2. When i select any value from the dropdown list (eg. 10 from GSM). the value is assigned to all other drop down.
[shown in image(3) next post]
(4) Again when suppose i select value for "Mill Name" Property as "Abc", it is assigned to all other drop down.
[shown in image(4) next post]
I want that a property value must be assigned to its respective Property only.
Please help me on this. Or suggest me another way out to accomplish such scenario.
Thanks
Ravi Patel -
SSRS reports from Lightswitch Html Client
I have created a Lightswitch desktop application that list the available reports that are stored in a table and also provides a button that when clicked launches the web browser to the URL for the report on the SQL server. My problem is now I'm trying to
create the HTML client for the application and have no experience with Java Script. Does anyone know how to accomplish the something that I did on the desktop application on the HTML client?
Below is the code that I used to open the URL in the browser in the desktop application.
Imports Microsoft.LightSwitch.Threading
Imports System.Runtime.InteropServices.Automation
Namespace LightSwitchApplication
Public Class ListReports
Private Sub RunReport_Execute()
' Write your code here.
Dim uri As New Uri(ReportsSet.SelectedItem.ReportAddress) 'website stored in the ReportsSet.ReportAddress field
If (AutomationFactory.IsAvailable) Then
Dim shell = AutomationFactory.CreateObject("Shell.Application")
shell.ShellExecute(uri.ToString)
ElseIf (Not System.Windows.Application.Current.IsRunningOutOfBrowser) Then
System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank")
End If
End Sub
End Class
End NamespaceThis may help:
Creating Reports in LightSwitch HTML Client
// Show Loading message
var LoadingDiv = $("<div></div>");
var Loading = $("<h1> Loading Report...</h1>");
Loading.appendTo(LoadingDiv);
LoadingDiv.appendTo($(element));
// Get Report
var HTMLContent = $("<div></div>").html(
"<object width='650px' height='650px' data='../reports/ReportViewer.aspx?SurveyId="
+ contentItem.screen.SurveyId + "'/>"
// Make report appear on top of the Loading message
HTMLContent.css({
"margin-top": "-50px"
HTMLContent.appendTo($(element));
Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book
http://LightSwitchHelpWebsite.com -
Extending Screens for Multi-Select in the LightSwitch HTML Client
Hi i
read Mike Droney's article of
Extending Screens for Multi-Select in the LightSwitch HTML Client
But i just want to understand the code, so what is the ‘__isSelected’ property? from where does it come?
why does the contentItem.value.details have an ‘__isSelected’ property?
is the value of the contentItem not the screen?
and also how can i implement the ‘Can Execute Code’ only if one or more check boxes are checked?
ThanksBut i just want to understand the code, so what is the ‘__isSelected’ property? from where does it come?
why does the contentItem.value.details have an ‘__isSelected’ property?
is the value of the contentItem not the screen?
and also how can i implement the ‘Can Execute Code’ only if one or more check boxes are checked?
The '__isSelected' property is a private member of the class msls.ContentItem related to the backing data for the selected item. That is to say, it would be a private member if JavaScript actually had encapsulation and information hiding like a typical
object-oriented language. I like to reference David Herman's description from his book
Effective JavaScript:
Often, JavaScript programmers resort to coding conventions rather than any absolute enforcement mechanism for private properties. For example, some programmers use naming conventions such as prefixing or suffixing private property names with an underscore
character (_). This does nothing to enforce information hiding, but it suggests to well-behaved users of an object that they should not inspect or modify the property so that the object can remain free to change its implementation.
...which means that it's generally not recommended to directly get or set backing data properties like __isSelected, instead working with the public property 'selectedItem', although it may work fine in certain cases like this one.
To make _canExecute fire only when an item in the list is selected to enable a button method, try:
return (screen.Contacts.selectedItem !== null); -
Runtime Error in VS2012 (Update4) LightSwitch HTML Client
I have a desktop (Silverlight) application, I upgraded the project to add the HTML Client. Now when I run the HTML Client, it shows this message box on the browser:
"The application could not be loaded. Please try refreshing the page. Failed to load model: failed to parse the model JSON string. Failure reason: syntax error."
I started my desktop application in VS2012 Update 2, and now it is in the Update 4. The interesting thing is that when I make new Project and then add HTML Client, I will not receive this error and it works fine.
It shows this error only on that specific project (Which I started on VS2012 Update2, later Update3 and now Update4) and that project is very big (more than 100 tables and screens), therefore I can not make that from scratch again.
I have to add HTML Client to my project. I really appreciate if someone can help me."The application could not be loaded. Please try refreshing the page. Failed to load model: failed to parse the model JSON string. Failure reason: syntax error."
Hi Keysen,
First you need install Microsoft.LightSwitch.Client.JavaScript.Runtime 2.5.2. This update can be downloaded from the NuGet Gallery, see:
http://www.nuget.org/packages/Microsoft.LightSwitch.Client.JavaScript.Runtime/
Because this issue is project specific, you can also turn the build output, in the
Options window, find Projects and Solutions >>
Build and Run. Find Diagnostic in the drop-down for MSBuild project build output verbosity. It will give detailed information why this happens.
Please let me know if there is anything that I can do to help.
Best regards,
Angie
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
SetProperty on OData model - update multiple entities before submitChanges on batch
I have a list in my application:
This data is bound to an OData model.
If I perfrom call I can retrieve the data fod the "fridge" item:I can retieve the OData for item 456.
this.getView().getModel().getProperty("/Items(BookingId='123',ItemId='Fridge')")
Therefore I can set the couonter like this:
this.getView().getModel().setProperty("/Items(BookingId='123',ItemId='Fridge')"+"/ItemCount", 6)
But once I have done this "SetProperty" call I am now unable to set any other properties on any of the other items!
What I want is to be able to change as many items as I like and then on SAVE do a batch OData PUT to update the values in the backend.
If I'm honest what I really want is to be able to do a DEEP INSERT into my OData provider, which contains a Booking, with nested sub-items..
Booking 1:m Items
How can I do this whilst also using the "setProperty" method?
setProperty is great in regards to if I make changes and then hit "CANCEL" I can call "resetChanges" to undo any changes.. but at the moment I can only change ONE of these counters before commiting my changes...
Surely this must be a common requirement, to make many changes in the front-end to multiple entities and then POST/PUT them all at once?
Thank you for any adviceA seemingly bug in SAPUI5 ODataModel setProperty() funtion
-
How to access the C# file in server from Lightswitch HTML Client
Hi,
In that LightSwitch HTML Application i have some c# file in the server project.How can i access those C# file in the screens (HTML Client project )
thanks,
goblalakrishnan s
gobalakrishnan SHi,
with implementing Generic File Handlers (.ashx)
See follow link:
http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/174/Full-Control-LightSwitch-ServerApplicationContext-And-Generic-File-Handlers-And-Ajax-Calls.aspx
regards
j.nord -
'Days Elapsed' computed field in lightswitch HTML client
I am developing a simple lightswitch HTML application to keep track of research experiments. I have a table called 'Experiments' and one of the fields is 'ExperimentDate'. I want to display the number of days that have passed since the date of experiment.
Is there any way to do this?Use a custom control to display 'ExperimentDate' and display the calculation. Use in-built JavaScript datetime functions or add a JavaScript library such as moment.js. Similar to this MSDN article sections:
Format a Date
Moment.js
You can see the use in this
stackoverflow post.
var date1 = new Date("02/Feb/2015 00:00:00"),
date2 = new Date("25/Feb/2015 10:09:00"),
diff = date2.getTime() - date1.getTime(),
days = Math.floor(diff / (1000 * 60 * 60 * 24));
Cheers
Dave
Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer. -
LightSwitch HTML Client pubished on azure get an 400.0 bad request error
Well, I have this problem: "Request failed with status code '400' and the status text 'Bad Request'." when I run my LightSwitch HTMLClient application that are published in Azure Web Applications.
I already look everywhere for 3 days and still could not find the answer to this problem.
I hope someone in this forum can help me.
Thanks.Hi, thank you for respond.
let's see, the fiddler throws these:
NOTICE: Don't follow the links, they are dummies
GET http://myapp.azurewebsites.net/ApplicationData.svc/$metadata
400 Bad Request (text/html)
The Request
GET /ApplicationData.svc/$metadata HTTP/1.1
MaxDataServiceVersion: 3.0
Accept: application/xml
Referer: http://myapp.azurewebsites.net/HTMLClient/default.htm
Accept-Language: es-MX,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Connection: Keep-Alive
Host: myapp.azurewebsites.net
Cookie: ARRAffinity=354b4b5b87b2f1e4e8b6c19a5566c6e055bf3e4047b54b4d2ea846ba1b33d561; msls-client-parameters=preferredLanguage=es-MX; ASP.NET_SessionId=bkf52whz0rkufhcxmqrfuirm
The Response
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Content-Type-Options: nosniff
X-Powered-By: ASP.NET
Date: Wed, 01 Apr 2015 04:23:39 GMT
Content-Length: 1647
Connection: Keep-Alive
The azure logs, the lightswitch diagnostic and the debugger not show any difference from these. -
Lightswitch HTML Client - beforeApplyChanges only fires once
Hi,
I have a standard Add/Edit screen created by Visual Studio with the standard save button in the top right-hand corner. In my beforeApplyChanges function I have the following code:
if (!screen.OrderAllocation.OfflineAdType) {
screen.findContentItem("OfflineAdType").validationResults = [
new msls.ValidationResult(
screen.OrderAllocation.details.properties.OfflineAdTypes,
"This is a required field")];
return false;
This fires correctly if someone tries to save the object without an OfflineAdType. However, if they then correct the error by editing it within the screen, and then click on the standard save button - a message box pops up saying there's validation errors
on the page. BeforeApplyChanges isn't called.
How do I clear these validation errors beforehand?You need to clear the validation results. You can also add a change listener to update any time the value changes. See the answer to this post.
https://social.msdn.microsoft.com/Forums/en-US/08af462d-a094-44b2-bf3c-a3cd5f7a40a9/hmtl-client-screen-validation?forum=lightswitch -
How to show/hide build in search box in javascript for LightSwitch html clients?
Hi
For each collection on content item, there is built-in showSearch button we can add, once the user clicks on the search, a pre-built-in-search-box shows up above the collection so user can search items in the list. How can I show/hide the pre-built-in-search-box
in javascript?
Any help will be appreciated
The built-in showSearch on content item
The user clicks the search button, and the pre-built-in-search-box shows up to allow user to enter search terms
jlHi Joe,
Welcome to Lightswitch forum.
If you want to show/hide showSearch button, you can execute this line to show the button,
this.FindControl("showSearch").IsVisible = true;
Or execute the line below:
this.FindControl("showSearch").IsVisible = false;
Please let me know if there is anything that I can do to help.
Best regards,
Angie
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
HTML Client: How to get the content/value of a custom control?
I made two Custom Controls named, "CustomControl_1" and "CustomControl_2".
In the render function of "CustomControl_1", how to access the value of "CustomControl_2"?
For example,
myapp.BrowseOrders.CustomControl_2_render = function (element, contentItem) {
$(element).text("Some Value");
myapp.BrowseOrders.CustomControl_1_render = function (element, contentItem) {
$(element).text( Value of CustomControl_2 ? );I would recommend creating screen properties and binding the controls to those screen properties. Then you can easily get a reference to any value. See this article for an example of the process using custom controls:
Using The Clippy Agent in the Visual
Studio LightSwitch HTML Client
Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book
http://LightSwitchHelpWebsite.com -
LIGHTSWITCH HTML ENTITY SOFT DELETION
Hello all,
I am working on LightSwitch HTML client application. I have an issue regarding entity soft deletion.
For your kind information, I have also referred Beth Messi's link:
http://blogs.msdn.com/b/bethmassi/archive/2011/11/18/using-the-save-and-query-pipeline-to-archive-deleted-records.aspx
My Scenario:
I have an Accounts table which is related to other tables.
In Accounts edit screen, I have a delete button. On deleting account from edit screen Account should be marked as deleted in database(i.e. soft delete) if it has no reference in any other table, otherwise show client side an error message
myapp.EditAccount.DeleteAccount_Tap_execute = function (screen) {
// Write code here.
screen.Account.deleteEntity();
myapp.applyChanges().then(function success() {
// Delete successful message.
}, function error(e) {
// Delete failure message.
According to Beth Messi's example: On deletion, the entity will discard changes and mark the entity as soft deleted.
So, If data is discarded then I do not get the server side exception " Could not delete. entity is in use." and my code inside function error() could not execute.
Any different way to accomplish this is also appreciated.
Thanks,
Ravi PatelHI Ravi,
As Beth’s blog said, it marks records for deletion without actually deleting them from the database. It discards the changes, this reverts the deletion.
As I know, myapp.applyChanges(), calling apply will save all the changes of the current changeset. If only one changeset exists, it will save them to the database. If the current changeset is a nested scope, it will commit the changes to
the parent changeset. I don’t think you can use myapp.applyChanges()
method in this scenario.
Best regards,
Angie
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Repro steps:
create new LightSwitch HTML C# app
Attach to Northwind OData service - http://services.odata.org/V3/Northwind/Northwind.svc/
include Order_Details, Orders, and Customers
add screen -> browse data, choose Order_Details
in the tile list that comes up, add other screen data, Order.Customer.ContactName
delete the 3 columns it added by default (deleting them isn't necessary to cause the issue, just makes the issue more obvious)
F5 and F12 in the resulting browser and make sure to check the Network tab
The resulting tile list shows just the contact names of the customers for the orders, as you'd expect, but they fill in slowly instead of all at once.
In the Network tab, you'll notice the first data request is what's expected in terms of including the associated child and grandchild entities
http://localhost:54553/NorthwindEntitiesData.svc/Order_Details?$expand=Order/Customer,Order&$top=45
Now, I'm a little confused at this point why it's not using $select to only fetch the particular properties needed, instead of it including all the Order and Customer properties as well, but that's secondary to this particular issue.
If you check the response, you'll see that the JSON returned definitely includes (as you'd expect) the Order and Customer, and the Order.Customer.ContactName in particular is definitely included - here's the first few lines of the response (reformatted to
be readable)
"odata.metadata": "http://localhost:54553/NorthwindEntitiesData.svc/$metadata#Order_Details",
"value": [{
"Order": {
"Customer": {
"CustomerID": "VINET",
"CompanyName": "Vins et alcools Chevalier",
"ContactName": "Paul Henriot",
After that is a bunch of further requests for Customers and Orders based on id, even though the first request already included all the data we need to display them.
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27VINET%27
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27TOMSP%27
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27HUNGO%27
...etc...
As you'd imagine, these requests have a pretty big negative effect on performance, especially if you have multiple columns exhibiting this effect.
Is this By Design? Am I doing something wrong? Is there a workaround for this?
Thanks!After that is a bunch of further requests for Customers and Orders based on id, even though the first request already included all the data we need to display them.
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27VINET%27
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27TOMSP%27
http://localhost:54553/NorthwindEntitiesData.svc/Customers?$filter=CustomerID%20eq%20%27HUNGO%27
...etc...
This really has bad impact on lightswitch performance, you can submit it to Visual Studio Connect Site, https://connect.microsoft.com/VisualStudio
Maybe you are looking for
-
Adobe LiveCycle Rights Management credentials needed to view protected pdf.
I recently downloaded a transcript and am not able to view it (in Adobe Reader) because I need to enter Adobe LiveCycle Rights Management credentials. How do I get these/access this information?
-
Songs will not play to the end on only one of my computers
Some of the songs in my library will not play to the end. However, I have come to realize this is only happening on one of my computers. The computer I sync with. The same songs will play on my laptop and iPad. ??? What gives?
-
Playing songs with "Shuffle" on
Hi everyone, I like playing my playlists with the "Shuffle songs" on to listen to differnt songs all the time, but there are certain songs that should always play together in order, Like on The Beatles "Abbey Road" (Golden Slumbers/Carry That Weight/
-
Importing side by side image sequences
Hi, I'm trying to figure out if there is a easy way to import 2 sets of image sequences into AE and have them side by side, so both sets will be inside 1 frame. Example of what I'm doing is having a phone conversation, instead of switching back and f
-
I shattered my iPod screen and it still works. Does anyone know the best way to replace the screen?