Visual Studio 2013 Lightswitch HTML Client - set data item to = table value

306 Views Asked by At

I have this scenario, I have a Parts Table and a Stock Table, the Stock Table contains a field Quantity, Now when this has a value I want my DataItem to equal this value, i.e. 1. The reason for this is validation for other parts of my screen but the Question here is How I display the value from a table view in a Data Item.

it has a databinding of Stocks(item).Quantity

using this code it doesn't work, however i know im on the right lines:

element.innerText = contentItem.screen.Stocks(item).Quantity;

please could anybody point out what im missing or where I have gone wrong? thanks

1

There are 1 best solutions below

0
On

got it working, on the screen created or beforeApplyChanges, this code within an if statement solved my issue:

if (screen.Stock.Quantity == null) {
    msls.showMessageBox("There is not enough in Stock, please enter a value equal to or less than the Stock Quantity", { title: "Aborted" }, { buttons: msls.MessageBoxButtons.ok }).then(function (result) {
        if (result == msls.MessageBoxResult.ok) {
        }
        screen.findContentItem("Stock_Quantity").value = 0;
    });
}