Here’s the code I’m trying to get to work, and I’ll explain it below:
--- tags: workorder site: "[[<%* dv = app.plugins.plugins.dataview.api; let array = await dv.pagePaths('"Sites"'); tR += await tp.system.suggester(array, array, true, "Which site?"); %>]]" address: "<%* dv = app.plugins.plugins.dataview.api; tR += await dv.page(dv.page(tp.file.path(true)).site).address; %>" ---
I’m creating a “Work Order” note and attempting to attach two metadata values: “site” and “address”.
The “site” metadata is fetched using DataviewJS inside of a Templater action - tp.system.suggester is fed an array of potential sites based on the DataviewJS request, which returns the path of the proper “site” note, which is then linked because of the enclosing double brackets.
The “address” metadata is fetched by referencing the new value associated with “site” on this note, and uses DataviewJS in the Templater action to get the address on that linked note. So for instance, if
site: "[[Sites/Liberty Bell.md]]", it would find the “address” metadata on the Liberty Bell note and return
Both of these lines of code work independent of the other, so if I just have the first one, it’ll return
Sites/Liberty Bell.md no problem. If I have site set to the “Liberty Bell” value already, the address metadata returns “Philadelphia” no problem.
But if I run them both simultaneously, it errors out because it thinks there’s no note listed at the note’s “site” metadata, even though it runs me through the selection process.