Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: New Script: Same Table Linked Records Backlinks

8963 1
cancel
Showing results for 
Search instead for 
Did you mean: 
openside
10 - Mercury
10 - Mercury

Explainer Video:

Base:

Code:

64 Replies 64

That was good… excellent idea, @openside!

nisha_elliott
5 - Automation Enthusiast
5 - Automation Enthusiast

@openside thanks so much for the code! Do you have any suggestions on how to tweak the code so that the fields (Source and Destination) are fixed, and we don’t need to select them upon running the script?

Read the top of the script code. It gives instructions on how to update the configuration section (labeled in the code) so you don’t have to answer those prompts each time.

Paul_Warren
8 - Airtable Astronomer
8 - Airtable Astronomer

Thank you @openside! This Script has been so integral to our workflow that we have now automated the process!

Below is the process laid out:

  1. Look up the “Previous Task” field of the “Next Task” (Field: “nextTasksPreviousTasks”)
  2. SEARCH() if the Primary Field, “Task ID”, is found within “nextTasksPreviousTasks”
  3. Look up “Next Task” of “Previous Task” (Field: “previousTasksNextTasks”)
  4. SEARCH() if the “Task ID” is found within “previousTasksNextTasks”
  5. IF() either SEARCH() fails then flag in “missingLinks”
  6. Create view filtered on “missingLinks”. (View: “BacklinkingAutomation”
  7. Trigger Automation based on “BacklinkingAutomation” view.

The Automation triggers your script with a few modifications to eliminate calls to “Output”.

Works beautifully! :grinning_face_with_big_eyes:

Theo_Michel
6 - Interface Innovator
6 - Interface Innovator

@openside do you know of any way to do this automatically when a forward link is created, rather than having it be run manually on a large batch?

now with automations you could set it up to listen for changes to the initial link field and then run a modified version of this script that just processes that single record.

I just tried that and it works, but has a major limitation: in the automations you can’t receive the value of the changed field, if the changed field is a linked record field. This means that you don’t know what changed, which means (I think) that you have to do a full walk of the table, basically running your whole script every time a change is made. I tried this on ~180 records and it took seconds to run. I’m very nervous about what will happen when we get to thousands of records.

Am I wrong about the automation not receiving the value of the changed field, or about the implication of that?

Thanks!
Theo

Correct.

Not necessarily. Because you have the record ID of the triggering record, that can be passed to the script via an input variable. Run a query on the table, then use the getRecord method on that query to select the specific record that triggered the automation (using that input variable). That will let you read any of its fields, including the link field, which will return an array of objects for the linked records. Iterate through that array and add links back to the triggering record. No searching needed.

But what if the change removed a record link rather than adding one? Without doing a full walk to find them, how do you avoid orphaned back-links?