Model Lookup returns a negative value with no data in the model

We have a UI only model lookup to an aggregate model of quote line items to return the value of a specific product to the Quote model. However when there's no product in the quote line items the formula returns a -1 value. The model lookup formula we're using is: MODEL_LOOKUP(QuoteLineSum, sumSubtotal, product2SubFamilyc, "Management Discount") where subfamily is the specific product we need to pull the value for. We've also tried a JS snippet to reevaluate the formula and it still shows -1.

var params = arguments[0],

    $ = skuid.$;

alert('in js');

var model = skuid.model.getModel("Quote");

model.evaluateFormulaFields();


We're completely stumped as in the console the QuoteLineSum object has no data rows with a value of -1 but in the Quote object where the UI formula lives, the data rows are showing the -1 value.


Anyone have any insight?

Best Answers

  • Matt Wyre
    Matt Wyre ✭✭
    Accepted Answer

    Never mind... We figured out that the model was being queried multiple times and we needed to set a condition to abort instead of deactivate.

    The interesting thing though is if you requery the model of a model lookup and the search value is no longer present, it doesn't clear the formula value (as it should)

  • Skuidward Tentacles (Raymond)
    Accepted Answer

    You could add an:

    IF(IsBlank({{$QuoteLineSum.data.length}}),0,MODEL_LOOKUP(QuoteLineSum, sumSubtotal, product2SubFamilyc, "Management Discount"))

Answers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!