Fetch all row mentions in a canvas?

I would like to fetch all @refs inside a Canvas object, so that I can use it to auto-populate table relationships. In other words, if someone includes @Alora in the canvas, then the Desired Output column would automatically create a reference to the Alora row in my Characters table:

The formula behind Actual Output is this:

Unfortunately the value property is not exposed when converting a Canvas to JSON, so this:

Becomes this:

So there’s currently no way to fetch the object, even though I’m able to fetch the container that holds the object. I really don’t want to resort to doing plain-text searching for hundreds of character names listed within numerous thousand-word essays. I doubt that’ll perform particularly well at all.


Your actually Can do it!

It’s something like

ThisRow.canvas.split(“ “).filter(currentValue.in(listcombine(table1, table 2, table 3)))

Essentially - you turn a canvas into a list where each entry on the list is a single word.

Then you filter your returned list to check if the currentValue is in side of another list (aka the target table the @ reference is Coming from)

Let me know if you need a sample doc! I’ve done it a couple times before

Here’s some lengthy documentation on some of those formulas in case it helps

Everyhing to know about split

Everything you need to know about in()

Hah. While there’s no way to get the values of @-refs from a canvas in a calculation formula, there is a trick to do it that involves an action.

You have to copy the canvas into another (text) column, and that column will then have @ref values inlined:

Then from that new column you can extract references like this:

You can actually use these as selection items on your Relation or People columns respectively.

Need them in the @-ref format? Just .Concatenate() to each of them:


P.S. Page atrefs work too:

Fascinating discovery! I’ve gone with a more explicitly structured approach for now, but I’ll definitely be keeping this one in my back pocket!

There’s not? Then how did I do it. . . I’ll have to go dig up my doc that I did it in for reference.

In canvas, @-refs are not included with their values.

The solution you proposed only works if you assume:

  1. @refs are single words (since you’re splitting on each whitespace, i.e. into individual words)
  2. you don’t have (or don’t mind) false positives on words that are not @-refs matching up with rows from your tables
  3. there’s no ambiguity in which words match which rows,
  4. and finally, both the text that you’re splitting, and the list of rows you’re matching against, are not very large — otherwise this formula becomes a real resource-eating monster at O(n * k) complexity.

I’d love to be proven wrong :slight_smile: but last time I was doing this @ref-extraction magic on regular Big Text values, a few Codans dared me to do this on canvases, claiming it was impossible.

1 Like

Ooooh interesting. I bet I’m wrong then =] will check when I get to computer next week

1 Like

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