how to set filter default values - specifically date range in this use case

  • 3
  • Question
  • Updated 3 years ago
  • Answered
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 4 years ago

  • 3
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Official Response
Here it is. Dynamically setting the date range in a filter.





(function(skuid){
    var $ = skuid.$;

    skuid.$(document.body).one('pageload',function(){
    
        var taskTime = skuid.$M('TaskTime'),
            startDate = new Date(),
            endDate = new Date(),
            startDateOffset = -1,
            endDateOffset = 21;
        var tastTimeStartDateCond = taskTime.getConditionByName('Sync_Start'),
            tastTimeEndDateCond = taskTime.getConditionByName('Sync_End');
            
            startDate.setDate(startDate.getDate() + startDateOffset);
            endDate.setDate(endDate.getDate() + endDateOffset);
            
            taskTime.setCondition(tastTimeStartDateCond,skuid.time.getSFDate(startDate));
            taskTime.setCondition(tastTimeEndDateCond,skuid.time.getSFDate(endDate));
            taskTime.activateCondition(tastTimeStartDateCond);
            taskTime.activateCondition(tastTimeEndDateCond);
            
            taskTime.updateData();
    
    });
})(skuid);