Mobile: 'filter' model by date, and scroll through dates on swipe

Goal: On load of mobile page show events where the Date__c field is today. Swipe left to see events for the next day; swipe right to see events for the previous day.

Since the mobile page builder doesn’t have tables and filters, I’m using javascript to interact with a condition on the model. The model starts with filterable condition Date__c = 'TODAY’

I wrote the following nextDay snippet:

var model = skuid.$M('ApptInteractions'),<br>&nbsp; &nbsp; condition = model.getConditionByName('Date'),<br>&nbsp; &nbsp; curDate = condition.value;<br>&nbsp; &nbsp;&nbsp;<br>var jsDate = skuid.time.parseSFDate(curDate);<br>jsDate.setDate(jsDate.getDate()+1);<br>var nextDate = skuid.time.getSFDate(jsDate); <br>model.setCondition(condition, nextDate);<br>model.updateData();

The problem I’m running into is that condition.value = ‘TODAY’, which apparently is not a date. So I end up with jsDate = FALSE.

I could use the Date__c field from the first row in the model to get curDate, but there may be a situation where there aren’t any rows in the model, and I still want to be able to see the new and previous.

Anyone see a way around this?

Write an if statement to look for ‘TODAY’. If so, then create a javascript date object for today.

Brilliantly simple. Thanks!

Running into another problem. I can set the filter value to a date, but none of my rows with that date are showing up. I think it is because the field is a DateTime?

Is there any way to communicate to the filter “this day at any time?” Rather than “This date at a specific time.”

Create a formula field on the object to calculate the date from the date time field. Then use this in your model.


Pat.  You are approaching guru status.