Updating computed fields in Lightswitch

246 Views Asked by At

How can I update computed field value programmatically without refreshing screen? When _Compute method is executed?

1

There are 1 best solutions below

0
On

not a tested solution but based on the HTML Client and how that works, a solution to add a save button that updates a value

private void Save_Click(object sender, RoutedEventArgs e)
{
entity.ComputedProperty = entity.value1 + entity.value2;
}

tested HTML method:

myapp.AddEditTest.Save_execute = function (screen) {

var oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
var StartDate = screen.Test.StartDate;
var EndDate = screen.Test.EndDate;

screen.Days = Math.round(Math.abs((Start.getTime() - End.getTime()) / (oneDay)));

}

screen.Days is the Data Item I have added on the screen which acts like a computed property. running this on a save button updates and displays this value for me.