Evaluate JavaScript (inline)

What I’m trying to do

I have a few notes that I want to update automatically.

For example, I maintain a table with meetups in my area that are on a fixed schedule (e.g. first saturday of every month). I now want the day of the next meetup to be calculated dynamically:

Meetup Schedule Next Occurence
x Every second Friday 12.05.2023

Things I have tried

  • Calculating the actual date is not that hard. I have written a function that I can re-use with CustomJS
  • I can also output an inline DQS (DQL, JS and Inlines - Dataview)

What I need

  • Importing and calling the function is not possible as a one-liner - or is it??
  • Can I import at the beginning of the file and call the function in-line later in the file?
  • Is there a way to have multiline “inline” queries? Also without messing up the table layout?

Is possible to call CustomJS code as one-liners, but they can be long lines if you don’t choose your names wisely. See DataviewJS Snippet Showcase - #308 by holroy

Within Templater javascript code, they share the same scope, which would allow for declaration at one place, and references other places. Alas, I don’t think you can do the same with Dataview.

I don’t think you can do multiline inline queries, but you can call dv.view() functions inline, where those functions can be multiline. (Kind of similar to CustomJS stuff)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.