I'm using Visual Studio 2013 LightSwitch to attempt to build an HTML application. After trying for several hours to get a "computed" column/field to show up in the HTML client, I realized it's not possible. I thought about building a trigger to fire on the table, but that won't get pushed when I publish the application. So, without using a RIA client, what's the best way to calculate using two or more datasource fields and store in another? It can be triggered when the user clicks the save button or even when the fields contain data that can be computed.
For example, Table Users (before):
First_Name (string) Last_Name (string) Stored_Full_Name (string)
John User NULL
Jane Doe NULL
When the user clicks save, or when first_name and last_name are not null, "Last_Name, First_Name" is stored as a single column in the Stored_Full_Name column in the same table.
For example, Table Users (after):
First_Name (string) Last_Name (string) Stored_Full_Name (string)
John User User, John
Jane Doe Doe, Jane
I'm assuming the same technique could be used to calculate costs or other items?
Any example code would be greatly appreciated.
For simple computed properties, you can always create functions on the Users prototype. It's explained in this blog post: http://lobfactory.wordpress.com/2013/05/03/computed-fields-in-the-html5-client/