Inline dataview query ( "-" as output)

What I’m trying to do

I’m trying to extract the YAML metadata from the current file into the same file via inline dataview query.

  • The dataview plugin is enabled
  • Inline dataview queries are enabled

Markdown YAML

---
date_start: <%tp.date.now("YYYY-MM-DD")%>
class: book
type:
tags:
cover: 
---

Code

Last modified: `=this.file.mtime`
Last modified date: `=this.file.mday`
Tags: `=this.file.tags`
Aliases: `=this.file.aliases`
Class: `=this.file.class`

Result

Screen Shot 2022-09-19 at 13.51.46

As you see I only see the “-” as output of this inline query. Im in preview mode.

To start, you have an invalid frontamatter (check for error message)… I guess you need to quote a code, if not it’s considered an invalid symbol.
For now, preview mode isn’t a reliable for inline queries.
Inline queries as values aren’t a good choice (because they work well only inside the current file, not for external queries… why? because the real value is =the inline code, not the outputted value. if you get the value =this.file.name in a table query placed in another file, this means the current note, not the original one)

EDIT: Ignore my post. I just misread your goal (I thought you’re trying to build a frontmatter with inline queries). @anon63144152 is right: only implicit fields needs the prefix file.; custom fields are page level fields, without prefix.

  1. Changing to:
Class: `=this.class`
  1. Navigating away from the page and then back to it works fine in my test. Markdown file in the preformatted text below.

---
date_start: 2022-09-19
class: book
type:
tags:
cover: 
---

Last modified: `=this.file.mtime`  
Last modified date: `=this.file.mday`  
Tags: `=this.file.tags`  
Aliases: `=this.file.aliases`  
Class: `=this.class`  
1 Like

There was something wrong with Obisidan app. All solutions does’t help me to get rid of the “-” output. I disabled all plugins, restarted Obsidian app, enable the plugins and then all works like charm.

@mnvwvnm Thank you for explaining me the difference between the custom class and standard classes of YAML fields.

2 Likes

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