Linking rows using a lookup of a link causes odd behaviour


Bear with me, this one is a little difficult to explain, but I have built a demo to reproduce the issue in my Seatable cloud account that I would be happy to share as needed.

I have a table of items (Books, in my demo) and a table of categories. I would like to write a script to automatically link the items to their category. The complication is that I have a cross-reference table in between, to look up the short code of a category, and look up the correct row to link. In this case, the ID of the row to link is found in the linked colum of the cross reference table. (In my demo it would be trivial to eliminate the cross-reference table, but in my real case it is required, as it is significantly more complex including many categories per item.)

This isn’t exactly how the base.addLink function is expected to be used, but actually it works really well. For example, I can go to the Category table, and see all the items linked that were assigned to that category, and in the table view I see all the expected linked categories, and I can click on them as usual.

The only odd thing is that the row details pop-up shows “The linked row has been deleted”, even though it has not. Everything else behaves as expected. My question is, am I doing something wrong in my script, or is this a bug?

I’m using self-hosted version 3.3, but the issue reproduces nicely in Seatable cloud.

Screenshot and my script below.



-----script code:
const xref_table = base.getTableByName(‘Cross reference’);
const xref_view = base.getViewByName(xref_table, ‘Default View’);
const xref_rows = base.getRows(xref_table, xref_view);

const linkID = base.getColumnLinkId(‘Table1’, ‘Linked Category’);

//get the short code to look up
const short_code = base.context.currentRow[‘Short code’];

//find the short code in the cross-reference table
for (var i = 0; i < xref_rows.length; i++) {
var row = xref_rows[i];
if(row[‘Short Code’] == short_code) {
//found a match - look up the category, then link
base.addLink(linkID, ‘Table1’, ‘Category’, base.context.currentRow._id, row[‘Category’]);

Reverse-link is fine:

and the cross-reference table uses a linked record to the actual category:

Just a note that upgrading to v3.4 did not change this behaviour.