I'm getting this error with Dataview "Cannot read properties of undefined (reading 'file')." What can I do?

The full error message is Dataview (for inline JS query 'dv.el('span', dv.current().file.mtime.toLocaleString(DateTime.DATETIME_SHORT))'): TypeError: Cannot read properties of undefined (reading 'file') and only started appearing within the past few hours. These are my inline quries:

$= dv.el('span', dv.current().file.ctime.toLocaleString(DateTime.DATETIME_SHORT)). 􀐫 $= dv.el('span', dv.current().file.mtime.toLocaleString(DateTime.DATETIME_SHORT)

I can’t imagine making any vault changes that might lead to this.

I tried doing:

`$= dv.el('span', dv.current().file.ctime.toLocaleString(DateTime.DATETIME_SHORT))`
`$= dv.el('span', dv.current().file.mtime.toLocaleString(DateTime.DATETIME_SHORT))`

And it does simply work, so do you have some other stuff in or around, which might create the error? Do you get the same error if you copy this into a new note?

Bonus tip: How to present code properly in a forum post

If you want to showcase either markdown, or code blocks, or dataview queries properly in a forum post, be sure to add one line before and one life after what you want to present with four backticks, ````. This will ensure that any other backticks (like for code blocks or queries) is properly shown.

The queries suddenly work again, here’s my ramble:

I had another issue with my vault as well, where it would index my entire vault every time it started up. I did some troubleshooting for that as well, looking for any problematic files I may have introduced soon before or since that bug started appearing, but found nothing. I moved folders in and out of my vault during the process. I don’t know if that fixed either bug or both. Maybe my vault was corrupted?

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