Copying a canvas with object references to another doc

Hi, I’m currently running problems trying to transfer a table to another doc.

I have a table with a canvas column; the canvases contain formatting, formulas, tables, images, etc. My end goal is to be able to transfer all the rows from this table without breaking their canvases’ object references. It’s also important to note that I’m not trying to keep these references alive; I just want to take a static snapshot of whatever’s currently rendered in the canvas, and transfer it to another doc. Additionally, I can’t just hard-code everything, as the content is dynamic and I don’t know what will be inside of them.

I tried using cross-doc tables as well as the API to transfer the canvases. However, this ruins the canvas formatting (even with rich value format). The only workaround that I’ve found is to convert the canvas object to JSON using _Merge, send it to the new doc, then from there, reconstruct the canvas using _Deref_Object. This preserves the formatting, but also causes any references to display as “Object not found!”.

I found a workaround for formulas, but it doesn’t work for tables:

  1. Traverse the canvas hierarchy, collecting all formula IDs
  2. Create the JSON representing a dummy canvas that references a formula by its ID
  3. Render the canvas using _Deref_Object
  4. Replace all formula references in the main canvas with the static text from the rendered dummy canvas

I’ve abused the formula system trying to figure out a way to transfer the tables, but have not had any success. It feels like there should be an easy way to do this, without having to use private functionality.

In theory, I could use the API to fetch the table rows from the source doc, but then there’s no way to transfer them to the destination doc. Even if this was possible, I would quickly hit the rate-limit for writing.

Am I missing something, or should I just give up on this approach??

i think you need to request this as a new feature. i would vote for it.

using _merge() and deref_object() is unreliable as the internal representation of objects, especially formulas can change at any time in the future.

what is missing is a copy page and copy canvas function in CFL and in the API.

without that, these workarounds dont give what we need, and are unsupported and unsafe anyway.

respect

max

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