Model condition based on formula

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a Text Field “Year” and I want to add condition on model
based on dynamic year value (Current Year + 1). How I can achieve this.

I tried creating a formula field on object with option "field from another model", but it didn’t work.

please help!

Photo of khushboo

khushboo

  • 198 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
There might be an easier way, but you can do this with inline javascript on pageload.

Set your model to not load data on pageload, set up your condition filterable default on, and then add some inline javascript with something like this in it's contents:

$(document.body).one('pageload',function(){
var model = skuid.$M('MyModel'),
condition = model.conditions.getConditionByName('MyCondition');
condition.value = new Date().getFullYear();
model.updateData();
});