Open a random note using either dataview or templater *but from another vault*

What I’m trying to do

I have 2 vaults, one for “content” (lets call it A) and another for daily notes and other stuff (lets call it B). I want to have a random note from vault A to pop up on a daily note in vault B.

Things I have tried

A solution similar than posted here but specifying the vault path.

app.vault.getFiles(<THE_PATH_TO_VAULT_A>)
const files = app.vault.getFiles()
const random = Math.floor(Math.random() * (files.length - 1))
const randomNote = files[random]
dv.paragraph('[[' + randomNote.basename + ']]')

I haven`t found any solution for templater. Any of either would work for me.

Thank you!!!

So far I’ve not seen any way to access another vault other than using obsidian url’s, or using the obsidian-actions-uri plugin (which is under development).

And the latter one of these options is most likely your best bet. It supposedly can be used to execute some dataview query or similar to get information from the other vault. I’ve got no idea how well it works, and which limitation it runs under (or whether it’s currently maintained/working).

As you understand I’ve not used it, just heard a little bit about it.

What I’m more certain of is that the default API of Obsidian doesn’t easily allow access to another vault, so the code you’ve written does work within the current vault, but doesn’t apply to another vault. If you want to do this within the current vault, you’ve got to do all the file manipulation and extraction using pure javascript file operations, if I’m not mistaken.

1 Like

Thanks holroy. I will look that up, for now I think that I will make a static link to a page from the other vault and jump to a random page from there.

1 Like

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