Query Inline YAML fields

Things I have tried

What I’m trying to do

I have 2 notes as described as example below. NoteA contains inline fields Project Name & Project Duration. In NoteB, I tried to retrieve the Project Name and Project Duration values from NoteA. However, it does not return any value. I am guessing that I am not using the correct method in getting the inline fields values. As I managed to get values if I move these inline fields into YAML frontmatter. Any advice?

Note Name: NoteA

Project Name:: Project Avengers
Project Duration:: 10 months

Note Name: NoteB

All the following js return no values
$=dv.pages('"NoteB"').Project-Name
$=dv.pages('"NoteB"').Project-Duration

$=dv.pages('"NoteB"').project-name
$=dv.pages('"NoteB"').project-duration

I have also tried using dv.current in NoteA just to get the inline fields value. Same issue return no value.

Hi, anyone have idea? :pray: There was some typo in earlier post. Updated as below. Basically I am trying to get value with attribute name with a space in between ie. Project Name. I tried attribute name with “-” ie. Project-Name with not value return.

================================================================
I have 2 notes as described as example below. NoteA contains inline fields Project Name & Project Duration. In NoteB, I tried to retrieve the Project Name and Project Duration values from NoteA. However, it does not return any value. I am guessing that I am not using the correct method in getting the inline fields values. As I managed to get values if I move these inline fields into YAML frontmatter. Any advice?

Note Name: NoteA

Project Name:: Project Avengers
Project Duration:: 10 months

Note Name: NoteB

All the following js return no values
$=dv.pages('"NoteA"').Project-Name
$=dv.pages('"NoteA"').Project-Duration

$=dv.pages('"NoteA"').project-name
$=dv.pages('"NoteA"').project-duration

I have also tried using dv.current in NoteA just to get the inline fields value. Same issue return no value.

You have two issues:

  • you need to use dv.page() instead of dv.pages(), because you’re defining as source a page and not pages inside a folder or with a specific tag: use dv.page("NoteA")
  • the second issue is related with the use of the key as expression (this is a key:: value); in simple dataview queries you can use an “-” replacing the spaces (this-is-a-key) but in dataviewjs javascript doesn’t allow that and you need to use another index method:
`$=dv.page("NoteA")["Project Name"]`
  • in simple dataview queries you can use the “-” method (this-is-a-key ) and a js similar with the prefix “row”: row["this is a key"]
2 Likes

Thanks. It works :pray:

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