What I’m trying to do
I am trying to render a random list item which is part of a list in a file in my vault.
This is how the source file looks like:
Tips
- Tip1.
- Tip2.
- Tip3.
- Tip4.
- Tip5.
- Tip6.
Things I have tried
let quotesList = []
const listValues = await dv.page("Testfile").file.lists.values
for (q of listValues) {
quotesList.push('>' + q.symbol + " " + q.text)
}
dv.span('>[!tip]+ Tip of today\n' + quotesList[DateTime.now().toFormat("o") % quotesList.length])
And this is the error I get everytime I open up Obsidian
Evaluation Error: TypeError: Cannot read properties of undefined (reading ‘file’)
at eval (eval at (plugin:dataview), :2:55)
at eval (eval at (plugin:dataview), :6:108)
at DataviewInlineApi.eval (plugin:dataview:18618:16)
at evalInContext (plugin:dataview:18619:7)
at asyncEvalInContext (plugin:dataview:18626:16)
at DataviewJSRenderer.render (plugin:dataview:18650:19)
at DataviewJSRenderer.onload (plugin:dataview:18240:14)
at e.load (app://obsidian.md/app.js:1:720327)
at DataviewApi.executeJs (plugin:dataview:19171:18)
at DataviewPlugin.dataviewjs (plugin:dataview:19776:18)
Any ideas?
Many thanks in advance!
montharon