Link to properties and embedding of properties

Use case or problem

In my particular use case I am converting a spreadsheet system (for someone with little technical skills) into obsidian. The spread sheet is currently used because they can refer to specific information on different objects and than create complex PDF documents. For example, I have a spreadsheet of people with their name and address. In another spreadsheet I want to show the name of a person, which is easily achieved by simply typing for example =Sheet1!A2 to only show the name and not also the address. Overall the spreadsheets are currently used for storing the information, but also to dynamically crate documents. Side-note: Relational databases also work in this manner.

Proposed solution

  1. Make it possible to embed properties similarly to how block identifiers are embedded. Suggested syntax could for example be ![[Note#property]]. Please include autocomplete and links in the graph.
  2. Make it possible to recursively embed properties if the property value is a link. Let say a House has an Owner. I want to get the name of the owner like this ![[House#owner#name]].

Current workaround (optional)

Currently there are two workarounds, described as “a” and “b”:

a. Coded my own solution using templator with dataview.

  1. To simply show a property of a note. = [[Far 1, Jens Berg]].navn
    Not good enough because it is missing autocomplete, uses an unfamiliar syntax and missing the graph link.
  2. I created a custom js function to get one link deeper.
    <% tp.user.getPropertyFromPropertyReference(tp.file.folder(), "owner", "name") %>

Code (sorry, but it is currently very domain specific):

function getPropertyFromPropertyReference(
    folder,
    firstProperty,
    secondProperty
) {
    firstProperty = firstProperty.replace(" ", "-")
    secondProperty = secondProperty.replace(" ", "-")

    let dv = app.plugins.plugins.dataview.api

    let sakPages = dv.pages(`"${folder}/Sak"`) // some domain specific thing, sorry
    if (sakPages.length === 0) {
        return error_message(
            `Finner ikke saken (${saksnummer}). Husk at denne malen bare kan brukes i en sak.`
        )
    }

    // Fetch the firstProperty reference from the "Sak" note
    let firstLink = sakPages[0][firstProperty]
    console.log(firstLink)
    if (!firstLink) {
        return error_message(
            `Finner ikke ${firstProperty} i saken ([[saker/${saksnummer}/Sak]]).`
        )
    }

    let firstReference = firstLink.path.replace(".md", "")
    console.log(firstReference)

    // Access the telefon property from the referenced note
    let pages = dv.pages(`"${firstReference}"`)
    if (pages.length === 0) {
        return error_message(`Finner ikke ${firstReference} notatet.`)
    }

    let value = pages[0][secondProperty]

    return value
}

function error_message(message) {
    message = `\n> [!error]  Feil\n> ${message}`
    return message
}
module.exports = getPropertyFromPropertyReference

b. Using block identifiers. ![[My note#^my-list-id]]
I like the autocomplete, but the block identifiers are cumbersome to use and are quickly messy when used to for example describing a user with name, address, phone etc.

Related feature requests (optional)

I could not find any.
And please let me know if you have any suggestions to solve my use case with existing features.
Ut must be user friendly and possible to automatically fill inn information for documents that will be exported to PDF.

Additional notes

I think this is the obvious next step for properties which will make them extremely powerful and versatile. Making custom content management systems obsolete.

I might try to create this feature myself. I will comment on this topic when/if I start making it. Any help is welcomed.

6 Likes