Making a reference schema for a table external to the pack

Sync tables can reference another sync table within the same pack by using reference schemas. Is there a way to enable the same functionality for tables not in the pack, i.e. arbitrary user tables?

This seems to be automatically handled by coda when the display value for a row in a sync table is a link to a row in another table in the same doc. Is there any way to control this in the pack code?

1 Like

Hi @loucadufault - Unfortunately that isn’t possible today. Currently reference schemas can only reference sync tables, not regular user tables. Users can manually add lookup column to their sync tables, but it can’t be done in code.

Thanks for confirming. Is it the case that first-party packs such as the cross-doc pack do utilize such a functionality, e.g. in properly rendering chips for rows in cross-doc tables regardless of their provenance? Or does it actually just cleverly make use of other accessible functionality to achieve this?

Cross-doc lookup chips only resolve to other cross-doc tables.


The contrary — cross-doc lookup chips will only resolve if:

  • you sync not a view, but a base table where that reference is pointing

  • it’s synced from the same doc as your first table with that lookup column — i.e. you can’t sync DB Classes (referencing an import of DB Teachers) from the doc Classes and DB Teachers from its source doc Teachers — both syncs have to come from from the doc Classes.

TL;DR: in regular Cross-doc, not only it uses the same reference schema thing, but the reference schema is strongly tied to the table’s href.

It’s in my Sync Tables Pro pack where I’m jumping through hoops to work this around

P.S. Also the reason why you can’t reference tables in external packs is because all identifiers (identityName, dynamicUrl, rowId) get normalized into SHA256 identifiers along with the Pack ID — so even if you replicate the same three values above, normalized UIDs will read grid-dynamic-sync-12345-xxxxx.... and grid-dynamic-sync-67890-xxxxx.... (where those 12345 and 67890 are pack IDs), hence these won’t match and references won’t resolve.

1 Like

Probably an obvious question but since the pack docs don’t mention it: a sync table can only reference another sync table from within the same pack, or is there interop between packs?

Also how does the Cross doc pack manage to create a (broken) reference schema for rows in a table that is not cross synced by another Cross table in the same doc. Is it just a matter of creating a reference schema for that cross doc table that might exist in the future, and if Coda can’t resolve it, then it is greyed-out?

For dynamic sync tables, the identity name to specify in the reference schema is matched against the identityName of the sync table, or the return value of the getName() function? Assuming the latter as otherwise I don’t see how it would be able to resolve for multiple instances of that dynamic sync table.

I believe it is possible to make a reference between Packs, but specifying the packId field of the identity in the reference schema. That said, I haven’t tested it and don’t know a Pack that actually uses it.

Yes, exactly. Whenever you create a reference that can’t be resolved, it shows the value in the displayProperty field of that reference schema object. We usually recommend a valid like “Not found” if you don’t have a better value available.

The name of the table (from getName()) is not used for references. It’s a combination of identityName and dynamicUrl (and packId) that determine the unique table to reference. So for dynamic sync tables you need to make sure to specify the idenityName and dynamicUrl to form a complete reference.

1 Like