Help

Re: New Script: Same Table Linked Records Backlinks

4406 0
cancel
Showing results for 
Search instead for 
Did you mean: 
openside
10 - Mercury
10 - Mercury

Explainer Video:

Base:

Code:

64 Replies 64

Could you please point out where the recursion and inheritance occur?
I’m not seeing either.


I also find a few things in the script to be rather curious, such as line 67:

if(!currentAddedKidParents.includes( { id: modifiedRecord.id, name: modifiedRecord.name })) {

I bet this line does not do what the author intended. This condition will always evaluate as true. When using .includes() with an array of objects, JavaScript checks if the objects themselves are included, not the contents of the object. As written, the newly created object will never be included in the array, even if the array has an object with the same property values. Thus the includes() will always be false, and the ! negates that , making the condition always true.


There are a few other things in the script that imply that the author had limited experience with Airtable scripting when he wrote the script. For example, every pair of updateRecordAsync calls could be condensed into a single call, which would cut the run time almost in half. (And there are several other changes that could speed up the script, such as not having updateRecordAsync inside a loop.)

Could you please point out where the recursion and inheritance occur?
I’m not seeing either.

Sure, I haven’t been wrong all day, got to start somewhere :grinning_face_with_sweat: : is the findChildren function not both recursive and prototypal in places? The latter because it implicitly inherits the getRecord method and just rolls with it?

The former because of the way it creates its tree object, for example? Its async sync queue trigger is kind of recursive as well, it has a single stop/start condition and the interpreter is left to figure out the best ratios. This all comes together to form a solution that should work in any base, regardless of size, as syncing part keeps it keeps reusing its few functions for roughly (records.length/50)+1 cycles. or other properties - assuming the initial setup was correct.

Basically, it should work in any base, regardless of size and other properties, because it keeps switching between filling the queue and clearing it, for as long as needed.

Why do I have a feeling I’m flunking math and just how many scripts have been posted so far, I can’t even find that line 67. The thing I’m looking at and was looking at originally is a gist, I’m leaving just the canonical url here because some filter keeps complaining about repost attempts:

/on2air/b68450a877ab99fe4a93ef7f9c387568

And my original point was that this was good, not that the other thing was bad.

Maybe we’re talkin about different scripts here.

I was replying to this part of your post …

I thought your comments above were referring to the second script (theomichel/backlinks.js) because it has exactly 130 lines of code.

This script does not include the findChildren function. I also do not see any recursion or prototypical inheritance in this script.

On the other hand, the first script (on2air/same-table-backlinks.js) has 147 lines of code, and does include the findChildren function.


The findChildren function is not recursive. It does not call itself. Only syncLinks calls findChildren.

Thank you for pointing out this example of what you meant by prototypical inheritance. I was looking for something else, not a case of an object from the api using a method defined in the api.

Both scripts should work in any base of any size. (My script does as well.)

This is why I was looking for those features in the script. Both scripts have their merits, and both scripts have things that could be cleaned up.

I think the main concept missing when comparing the two scripts is that they serve different purposes.

  • One script is meant to be run manually to create backlinks in bulk, and requires only two linked same-table link fields.
  • The other script is meant to be run as an automation to maintain a system of same-table links that actually requires four same-table link fields.

My automation script for maintaining same-table backlinks is now available on my Gumroad store.

This is great @kuovonne, we need this (for parent / child relationships) but we also need one for sibling relationships… i.e. only one linked field with multiple entries.

E.g.

Running the script on:
Name Siblings
1 2,3
2
3

Should lead to:

Name Siblings
1 2,3
2 1,3
3 1,2

Is this possible? Or is there a workaround?

I’ve tried achieving this with automations, breaking out sibling IDs as separate formula fields and using lookups to create the updates… however this creates a recursive loop which I can’t seem to stop.

Help would be greatly appreciated!

It is possible to have a script to update sibling relationships. There are two potential scripts: a button script for establishing siblings relationships for existing records, and an automation script for maintaining sibling relationships on an ongoing basis. An automation script can include logic to avoid the recursive loop of unending automation runs. Please let me know if you are interested in hiring me to write these scripts.

However, usually sibling relationships are managed through a parent record. All of the siblings are linked to the same parent. The parent rolls up information about all the children/siblings, and then another rollup field passes the necessary information back down to all the children/siblings.

Hi @kuovonne thanks for offering your help. Yes, I’d appreciate your help with this. I’ve explored a parent record approach, but this seems more clunky. Since our focus is on each individual client, it’s best to know specifically who their family members / relationships are (spouse, children, parents, siblings, in-laws, extended family).

I’ve already used your script for spouse / children. Thanks for posting that.

How can we liaise with you to get you to write an automation(s) for siblings, in-laws and extended family in our contacts table?

@Tristan_Scifo You can book an appointment with me to discuss your needs. I use a booking calendar with a rolling two week basis, so I currently have only a few appointment slots available, but appointments on future days will open up as they come in the two week window.

It sounds like the same-table backlinks scripts works for parents/children, and spouses. Scripts for sibling same-table links is also doable. However, dealing with in-laws, extended family, and other blended family relationships can be0 tricky. For example, when adding a child to one spouse, should that child become a child of the other spouse and siblings of the other spouse’s children? These complex relationships might be more than you want to handle automatically.

We have an automatic linking feature - Same Table Linked Records plus 60+ more Airtable functions in the On2Air Actions app.

Here’s a tutorial:

______________________________________
Hannah - On2Air.com - Automated Backups for Airtable
KoenS
5 - Automation Enthusiast
5 - Automation Enthusiast

This is super helpful. Works like a charm. Thank you.