Hi there, I’ve got a question on dataview in combination with the Metadata Menu plugin.
What I’m trying to do
In the Metadata Menu plugin, I’m trying to create a multifile class which contains all incoming links to that file and allows me to choose from them. For this I need a dataviewJS query based around dv.pages(), since that is all that metadata menu allows as an acceptable query. Looking at similar questions online, the answer is often dv.current().file.inlinks, which usually would work swimmingly, but is not accepted by the metadata menu plugin. It has to be dv.pages(). Moreover, the output cannot be adjusted into a different data type, since metadata menu expects a dv.pages() output, meaning that any functions afterwards are only allowed to limit the search rather than change it. E.g. .map, .limit and .where are all allowed, but .inlinks is not, since that changes the output.
Things I have tried
I have tried all I can myself but am completely stumped. I have asked in the Obsidian discord under the dataview channel, but since I have some difficulty explaining myself given my limited dataview/programming knowledge and English not being my first language, it was difficult for them to help me. I am therefore asking here in the hopes of getting an answer that way.
I hope it is somewhat clear what I am trying to achieve.
Quick update: with some help from the discord I was able to get a whole lot closer, coming to the following query: $= dv.pages().filter(p => p.file.outlinks.values.map(l => l.path).includes(current.file.path))
Metadata menu accepts this but starts behaving weirdly, signaling missing values and getting stuck in a loop. Moreover, when I enter the query outside of metadata menu, I get the following syntax reference error: current is not defined
Thanks for the reply! Unfortunately this does not seem to work. This is probably beacuse metadata menu expects a dv.pages() output and not an actual link. I also tried the method of referencing the current file you describe in the query I commented earlier (i.e. dv.pages().filter(p => p.file.outlinks.values.map(l => l.path).includes(`"${dv.current().file.path}"`)), but this does not work either
So, I’d always tried .current(), in other words, with the parentheses, because that’s how I’d always see people use it. But this is the answer! current.file.inlinks works like a charm. Thank you so much for your help!