How do I set a model condition to the current date

  1. I have a model with an Intended Fiscal Year field and I want to set the model condition to the current year. Can I do this in the model condition? The data is displayed on a table in a tab and I tried adding using action when the tab is rendered to activate and set this condition but no records were returned.

    Here is what I did:

    Created condition on model filterable default off called IntendedFY and set it to None-A Blank Value

  2. Created an action whenever the tab is rendered to: a) Activate and set IntendedFY model condition to Year(Today()) and b) Query model.

I appreciate any help from the community on how to solve this.

Thanks!

Try using a UI Only field to calculate the year, then, Set the value of the condition to the UI only field value.

Raymond:

I don’t see how one can set a model condition on the value of a field in one of the model’s rows (which is what a UI-only field would be). Or am I missing something?

Also, the Intended Fiscal Year field in SalesForce is a pick list, which adds a wrinkle to this.

Thanks for your help!

I think a merge variable would work.

you should be able to use this if there is context for the model and row:

{{MyUIOnlyField}}

or this is you need to reference a different model or row (such as a UI only model)

{{$Model.MyModelName.data.0.MyUIOnlyField}}

I think it will work with a pick list as long as the value that gets inputted is one of the picklist values

To test your merge variable syntax, you can add a rich text field to your page and type the merge variable there, then preview the page to see what populated.

Raymond:

This is an interesting solution and I appreciate your help. However, the data is being displayed in a tab where I have an action when the tab is rendered to set this model condition and then querying the model, so I do not have context nor do I have a first model row to use {{$Model.MyModelName.data.0.MyUIOnlyField}} to set the condition as you suggested.

However, I may need to create a UI-only model to get today’s date.

I wonder if you or any of the Skuid community has been able to send something like an environment variable (like the date or time). I assume the only way to do this is to run a JS snippet?

Thanks again!

Hi, Meredith

Try creating a UI only model named “Year”.

Create a formula field in that UI only model named “ThisYear”.

Make the formula:

YEAR(TODAY())

then reference the result where you need using:

{{$Model.Year.data.0.ThisYear}}

UI only models load an initial row on page load which is row 0.