Checkbox in “Contacts” should sync Link in “Customers” (set + clear automatically) — JS vs Python + Automation

Hi SeaTable Community,
I’m trying to synchronize a “main contact” relationship between two tables using scripts.

Setup / Tables

  • Table 1: Contacts

    • Checkbox column: Is_Main_Contact

    • Link column: Contact_Company (link from Contacts → Customers)

  • Table 2: Customers

  • Link column: Main_Contact (link from Customers → Contacts)

Goal

When I change the checkbox Is_Main_Contact in Contacts:

  • If ON (true): the corresponding contact should be set as Main_Contact in Customers

  • If OFF (false): Main_Contact in Customers should be cleared again (removed link)

What I observe

  • Running my JavaScript sync script manually in the Contacts table works for setting the link (ON).

  • When I toggle the checkbox to OFF, the Main_Contact link in Customers does not clear automatically unless I run the script manually again.

  • I want the script to run automatically on checkbox changes, but in my UI I don’t see an automation option for executing scripts in background.

Attempts / Errors (summary)

  • Several JS API issues occurred during development (wrong parameter handling, link_id handling, getRows(…, view) with undefined view, etc.).

  • After fixes, the manual JS run correctly sets the link (ON).

  • I also tried a Python approach:

    • It shows no visible output (“no result”) and it does not reliably update data in the Customers table.

    • I have screenshots of the runner/editor and the “no output” behavior.

Questions for the community

  1. Is JavaScript suitable for automation triggers in my setup? (I don’t see a JS automation option)

  2. If Python is required: what is the correct Automation Trigger + Automation Action configuration to run a Python script when Is_Main_Contact changes in Contacts, so that it performs set AND clear on Main_Contact in Customers?

  3. If Python should work: why do I see “no output/no result” even when the script is executed? Are there known limitations depending on SeaTable edition/setup?

Thanks in advance!

Hi @Joachim,

First of all, there’s something I don’t understand in your Setup/Tables: If Main_Contact is a link column, don’t you need two links between your two tables? Because when you say:

I don’t understand how you determine which row of the Customers table you want to link to this contact if you don’t have a second link column linking every contacts of the company.
If I understand your problem correctly, you might actually not need any automation if your Main_Contact column is actually turned into a Link formula column:

  • you keep a link between the two tables so that you can link every contacts of a same customer
  • your Main_Contact column is a Link formula / rollup column where you check the option only lookup records that meet the following conditions : Is_Main_Contact is :check_box_with_check:
    This way, your Main_Contact column does what you want without needing any automation (but be careful: doing so, nothing prevents you from having several main contacts for the same company).

Now let’s assume I didn’t understand your use case, so I’ll answer your questions anyway:

  1. No, you can only run Python scripts via automations, not JS scripts
  2. Depending on what is the most easy to understand approach for you, you can either:
  • Create a single automation:

Your python script should then be able to deal to both Is_Main_Contact states (ON and OFF)

  • Create two separate automations: one to deal with Is_Main_Contact being changed to ON and the other one… well you get my point I think :sweat_smile:

As you can see, in this case, we added a Condition in the Trigger settings. Logically, if this is your preferred option, you’ll prefer having two separate Python scripts, one for each action (ON → linking the contact, OFF → removing the link)

  1. For this one, I have no idea. You should have joined the screenshot, because we lack some information for a proper answer :thinking_face:

Bests,
Benjamin