# Making a reference schema for a table external to the pack

**URL:** <https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449>\
**Category:** Making Packs\
**Created:** [August 31, 2022, 2:48am UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449 "2022-08-31T02:48:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![louca.developer](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/louca.developer/32/22685_2.png) [@louca.developer](https://connect.superhuman.com/u/louca.developer)\
**Post date:** [August 31, 2022, 2:48am UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/1 "2022-08-31T02:48:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [September 6, 2022, 1:55pm UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/2 "2022-09-06T13:55:24Z")

</div>

Hi @louca.developer - 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.

---

<div class="post-metadata">

**Author:** ![louca.developer](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/louca.developer/32/22685_2.png) [@louca.developer](https://connect.superhuman.com/u/louca.developer)\
**Post date:** [September 7, 2022, 6:48am UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/3 "2022-09-07T06:48:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [September 7, 2022, 10:10am UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/4 "2022-09-07T10:10:54Z")

</div>

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

Moreover,

> [@louca.developer](#):
>
> regardless of their provenance?

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](https://connect.superhuman.com/t/preview-cross-doc-plus-codenamed-my-opinionated-take-on-cross-doc/30318/29) where I’m jumping through hoops to work this around

https://www.youtube.com/embed/Mhrhdh79B-A?feature=oembed&wmode=opaque&list=PLlmBORQgXtrgLGnyY4lZ2zHdg-99fF7Xr

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.

---

<div class="post-metadata">

**Author:** ![louca.developer](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/louca.developer/32/22685_2.png) [@louca.developer](https://connect.superhuman.com/u/louca.developer)\
**Post date:** [November 10, 2022, 2:54am UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/5 "2022-11-10T02:54:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [November 10, 2022, 3:18pm UTC](https://connect.superhuman.com/t/making-a-reference-schema-for-a-table-external-to-the-pack/33449/6 "2022-11-10T15:18:37Z")

</div>

> [@louca.developer](#):
>
> a sync table can only reference another sync table from within the same pack, or is there interop between packs?

I believe it is possible to make a reference between Packs, but specifying the [`packId` field](https://coda.io/packs/build/latest/reference/sdk/interfaces/core.IdentityDefinition/#packid) of the identity in the reference schema. That said, I haven’t tested it and don’t know a Pack that actually uses it.

> [@louca.developer](#):
>
> 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?

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.

> [@louca.developer](#):
>
> 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.

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.
