API Scripting Issue: updateRow returns success but linked records are not saved

Your Setup:

  • Environment: SeaTable Cloud (Free Edition)
  • SeaTable Version: Latest Cloud Version

Describe the Problem:

I am trying to automate linking rows between two tables (youtube and stories) based on a matching text column id_day. Despite the script executing without errors and the API returning a success status, the “Link to other records” column remains empty in the UI even after a hard refresh (F5).

The Logic:
The script finds all rows in stories where id_day matches the id_day in the youtube table. It then attempts to write an array of the stories’ _id strings into the link column.

Troubleshooting already performed:

  1. Column Type: Verified as “Link to other records” (NOT a Link Formula).
  2. Permissions: I am the base owner; no column-level permissions are set.
  3. Manual Link: Linking rows manually via the UI works perfectly.
  4. API Methods: Tried base.updateRow, base.modifyRow, and base.addLink.
  5. Internal Keys: Used the internal column key (hsUk) instead of the display name.
  6. Data Integrity: Verified that id_day values are clean strings and row IDs are valid.
  7. New Column: Created a brand new link column to rule out metadata corruption — same result.

The console log confirms that the script correctly identifies the rows and the number of IDs to be linked, but the database doesn’t seem to “commit” the changes.

Commands Executed:

// Example of the core logic used
const YOUTUBE_TABLE = 'youtube';
const STORIES_TABLE = 'stories';
const COLUMN_KEY = 'hsUk'; // Internal key for 'link_stories'

async function sync() {
  const ytTable = base.getTableByName(YOUTUBE_TABLE);
  const stTable = base.getTableByName(STORIES_TABLE);
  
  // Example of a single row update attempt
  const rowId = "A7x..."; // Valid Row ID
  const storyIds = ["JiR...", "C8O..."]; // Valid Story _ids

  try {
    // The API returns 'undefined' (Success), but no data is saved
    await base.modifyRow(ytTable, rowId, { [COLUMN_KEY]: storyIds });
  } catch (e) {
    console.error("Error:", e.message);
  }
}

Hi @anjou, and welcome to the SeaTable forum!

Updating links actually uses a special logic and functions. For JavaScript, you can find documentation here in the Seatable developer manual. Long story short, you’ll need to use the updateLinks function, which will, in your case, look like this:
base.updateLinks(linkId, YOUTUBE_TABLE, STORIES_TABLE, rowId, storyIds);
Please note that the linkId is not the internal key for link_stories, but the link id. You can get it for the first time by using the getColumnLinkId function:
const linkId = base.getColumnLinkId(YOUTUBE_TABLE, 'link_stories');

Bests,
Benjamin

1 Like

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