I try to get a property (description) of a secondary (linked) file displayed in the primary file with a dataview inline query:
= dv.page(“SecondaryFileName”).description
This isn’t working. Apparently Obsidian is not processing the inline queries at all. In read mode it produces the query that I entered in edit mode.
Did anyone encounter the same problem and found a solution.
Things I have tried
to check whether inline queries are processed, I also made a test with a minimal file only containing the most simple inline query
= 1 + 1
Also that isn’t producing the required result ‘2’ when going to read mode.
That wasn’t the solution, but your example pointed out the cause: I didn’t enclose my dataview inline in backward tick marks. Once I do that it works like a charm.
Thanks for helping out. I chatted with copilot for more than an hour going through everything, but never this came up.
The minimal inline query executes as soon as I included it in back ticks. Unfortunately my inline dataview query `= dv.page(“SecondaryFileName”).description` still doesn’t return the property.
It gives me an error: “Cannot call type ‘null’ as a function”
Also the inline query `= dv.pages().file.name` returns this same error.
Although the modes access the same functionality, they work differently and can’t be mixed in the same block.
By default, DQL inline queries start with =, e.g.:
This page's name is: `= this.file.name`.
By default, DataviewJS inline queries start with $=, e.g.:
This page's name is: `$= dv.current().file.name` .
Because your code contains a call to the JavaScript Dataview object dv, this is a DataviewJS query and needs to start with $=. But because you started it with a = it was interpreted as a DQL query and couldn’t be processed.
To run your query, you need to make it look like the following. (Note that this is a heavy query, so if you’ve got a lot of pages in your vault it will take a while to complete!)
All the pages in my vault: `$= dv.pages().file.name`
There are many more differences between DQL and DataviewJS. DQL is simpler to use, but DataviewJS is more powerful. I recommend checking out the docs if you’d like to learn more.
Thank you very much Craig.
You perfectly and clearly showed me what was wrong and proved that humans are still far more clever than AI (in my case Copilot)
And yes, as is often the case with us non programmers, I thought I could use all the power, without properly reading the guidelines. Your answer is not only solution but also encouragement to do what is right: read the guidelines