A few advanced tips for canvas column type

This is a great addition. There are currently two drawbacks which when properly resolved will make this feature much more flexible.

parentRow is not available from template pages. For which there are currently two workarounds:

  • To embed the template in the same (or a different) table as @Kelsey_Chan suggested.

  • or to create a formula on your template page

    RandomInteger(0, 1000000)
    

    and call that formula PageId, then for any data you need from the parent row inside of your template you do a formula like this

     TheParentTable.Filter(TheCanvasColumn.Find(PageId) > -1).First().TheColumnValueYouNeed
    

    What is happening here is that we are emulating the parentRow formula by creating a random id for each canvas and then searching for a row that contains a canvas with that id within itself.

The first approach is simpler and more future proof if you don’t mind having additional columns and filtering out template data. The second approach lets you have template pages and reference parentRow but might break at some point, and also you need to hide the various formulas on the page.

Referencing data from child canvases is difficult. There are some interesting use cases where for example the status of the parentRow depends on the state of tasks in a table within a canvas cell (basically a formula row that says that the parent row is done only when all tasks in the canvas cell are done). This is difficult to do correctly as canvas cells can all be different so there is no way to guarantee that a canvas cell will even contain a table. Here is an idea for the future, and a workaround:

  • Allow select lists to be displayed as as inline tables. This guarantees that all the cells are the same and can be easily referenced from the parent row. There are some hacks to do this but they are complicated and unreliable. For additional “freeform” data it can simply be added to another canvas column, the data doesn’t necessarily have to be in the same column. Although this still leaves the problem of referencing controls or formulas within a canvas cell.

  • A workaround: in your template add a formula like this

    "<1>" + TheTableInTheTemplate.TheColumnYouWantToExposeToTheParentRow.Sum() + "</1>"

    (of course you can expose any kind of data you like, Sum() is just an example). Then in the parent table to get the exposed data you do something like this (either within a formula column, or another formula)

     WithName(thisRow.TheCanvasColumn.ToText(), CC, CC.Slice(CC.Find("<1>") + 3, CC.Find("</1>")-1))
    

    <1></1> are just unique placeholders (inspired by HTML) that are easy to search for, you can use any identifier you like, for example: |-some value we're exposing-|, but keep in mind these identifiers need to be different for each value we’re exposing so :<1>value 1</1> <2>value 2</2> etc..

I hope someone finds these workarounds helpful.

7 Likes