SuggestedValue for DateArray Paramaters

Does anyone know how to make suggestedValue for a DateArray parameter work?

I currently have

coda.makeParameter({
  type: coda.ParameterType.DateArray,
  name: "ListOfDates",
  description: "A simple list of Event Dates",
  suggestedValue: Array(new Date("2000-1-1"), new Date("2000-4-1"), new Date("2000-12-25")),
}),

But coda appears to be casting the Javascripts dates into Text
image

Any help would be much appreciated.

Hi @Logan_Krantz - Unfortunately I don’t think we planned for using suggestedValue with Date or DateArray parameters and literal values, and as you found we don’t seem to handle it correctly in the Coda formula language. We do support using “precanned” date ranges, like this:

coda.makeParameter({
  type: coda.ParameterType.DateArray,
  name: "dateRange",
  description: "The start and end date.",
  suggestedValue: coda.PrecannedDateRange.Last30Days,
}),

When you add the formula to the doc, the suggested value will be a formula that calculates the start and end date dynamically:

image

Would that work for you use case? If not, can you provide more information about why you would like to have literal dates for suggested values?

Sure! I am working on a pack to create timeline diagrams.
This takes 2 lists as parameters. (List of Dates & List of Event Titles)
The two ways I expect this to be used are
Option 1. List of Dates = Table.ColumnOfDates & List of Event Titles = Table.ColumnOfText
Option 2. The user creating their own List() for each variables using Coda formulas.

I want both of these methods to be immediately apparent to new users so I have set up the suggested values to demonstration Option 2.
This way when a user creates a Timeline they can see it working immediately. Then alter it with their information.

See an example gif below.
chrome 2023-10-31 T08.13.29.859

Curiously, Even though the dates don’t come through correctly they still work. Still if possible it would have been nice to have the dates appear as coda dates.

1 Like

I saw you just published the Pack, congrats! What a creative addition to Coda.

I’ll file this bug with the engineering team, but it may be a while before it gets addressed. In the mean time, perhaps it makes sense to just pass date only strings (like “2023-11-01”) instead of Date objects in your suggested value, since that would work as well and is easier to read.

Thank you for the suggestion. It does not affect the function of my pack so I think I will have to leave it as is for now.

I did try to use an array of text strings instead however it appeared to cause some datatype validation conflict (DateArray != StringArray)