Last N Days model condition not working

  • 1
  • Problem
  • Updated 1 year ago
  • Acknowledged
  • (Edited)
I'm trying to have my model create a new row if the most recently created record was more than 15 days ago, because the user needs to create a new record if the most recent record created is more than 15 days old.

I've added a model condition for this purpose (see screenshot attached), and checked off "Create default row if model has none"...thinking that if the model doesn't find a record that meets my condition, it will create a new one... and I've tried all the operators (below) that I would think should do the trick...but I can't seem to get it to work...components tied to the model don't render at all.

CreatedDate = Last n Days: 15
CreatedDate >= Last n Days: 15
CreatedDate > Last n Days: 15

Where am I going wrong...?

Photo of Conlan O'Rourke

Conlan O'Rourke

  • 3,280 Points 3k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I’ve had similar issues and reported it. The ultimate conclusion was that n days ago is a range not a specific date so comparing it the way you are doesn’t work. What I would do is Crest a Salesforce field that returns true if today minus created date is less than 15 days. Then you can create a condition in your model based on whether that field is true or false.
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Skuidward is correct and the post he is referring to is this:
https://community.skuid.com/skuid/topics/-next-n-weeks-not-working

We have it catalogued with our developers and are working on putting out an enhancement.
Photo of Conlan O'Rourke

Conlan O'Rourke

  • 3,280 Points 3k badge 2x thumb
Hmmm....this workaround of creating the boolean formula field ((TODAY() - CreatedDate) <= 15) and using it as the condition doesn't seem to be working...when the condition is met...i.e. created in last 15 days, the record pulls up. However, when the condition is not met, the' Create default row if model has none' is not creating a new row.
Photo of Conlan O'Rourke

Conlan O'Rourke

  • 3,280 Points 3k badge 2x thumb
I think I may have found something...the condition works when "Load Model data on Page Load" is checked...but not when the model is loaded through an action on the page (in my case an action on the tab). 

In fact, it's not just the boolean workaround...it seems to work even with the Last_N_Days:15 condition.

So it appears the issue is with the tab action that Queries the Model rather than the Last_N_Days:15 condition...see links to screencasts below

Buggy: http://recordit.co/RRtzA5m82b

Working: http://recordit.co/wSAImiKXX8