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:
CanvasObject._Merge().ToText().ParseJSON(“$…children[?(@.type==‘InlineCollaborativeObject’)].id”)
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.
In canvas, @-refs are not included with their values.
The solution you proposed only works if you assume:
@refs are single words (since you’re splitting on each whitespace, i.e. into individual words)
you don’t have (or don’t mind) false positives on words that are not @-refs matching up with rows from your tables
there’s no ambiguity in which words match which rows,
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 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.