Issue with recurring todo item macro

I’m trying to add functionality for recurring items to GSD5. I’m almost there, but I’m having trouble with running the final macro to generate all of the recurrence dates. Basically I am taking the gsd_complete_date variable and incrementing it with some help from @EricShulman’s ParseDate function.

Right now, this macro in particular should just print out the gsd_complete_date + the number of days returned by the getDueDate macro.

\define createRecurItems()
<$list filter="[field:gsd_type[action]field:gsd_complete[true]has:field[gsd_frequency]]">

<<getDueDate {{!!gsd_frequency}}>>

</$list>
\end

<<createRecurItems>>

The getDueDate macro works, but here it is for context:

\define getDueDate(frequency)
<$let today=<<now "YYYY0MM0DD">> format="[UTC]YYYY0MM0DD"
     oneday={{{ [[24]multiply[60]multiply[60]multiply[1000]] }}}
oneweek={{{ [[7]multiply[24]multiply[60]multiply[60]multiply[1000]] }}}
onemonth={{{ [[30]multiply[24]multiply[60]multiply[60]multiply[1000]] }}}
  yesterday={{{ [<today>parsedate[unixtime]subtract<oneday>parsedate:unixtime<format>] }}}
   daily={{{ [{!!gsd_comp_date}parsedate[unixtime]add<oneday>parsedate:unixtime<format>] }}}
weekly={{{ [{!!gsd_comp_date}parsedate[unixtime]add<oneweek>parsedate:unixtime<format>] }}}
monthly={{{ [{!!gsd_comp_date}parsedate[unixtime]add<onemonth>parsedate:unixtime<format>] }}}>
<<$frequency$>>
</$let>
\end

This is the part that is not working as I expected:

<<getDueDate {{!!gsd_frequency}}>>

I’ve tested each piece separately - getDueDate works and the gsd_frequency variable is returning the right value, but when I put them together it just shows up blank. Is there something wrong with my syntax?

Thank you!
Bobby

Update - I got it working. I had to use the macrocall widget:

\define createRecurItems()
<$list filter="[field:gsd_type[action]field:gsd_complete[true]has:field[gsd_frequency]]">

<$set name="freq" value={{!!gsd_frequency}}>

<$macrocall $name="getDueDate" frequency=<<freq>> />

</$set>
</$list>
\end
1 Like

Just a few minor notes on syntax:

  • Instead of using the $set widget, you can use the newer (and more compact) $let widget:
<$let freq={{!!gsd_frequency}}>
<$macrocall ... />
</$let>
  • You can actually skip the $set (or $let) widget entirely, and specify the field transclusion directly as a parameter value in the $macrocall for getDueDate, like this:
<$macrocall $name="getDueDate" frequency={{!!gsd_frequency}} />

enjoy,
-e

1 Like

Awesome - thanks for the tips and the ParseDate function, @EricShulman !