Help

Re: New Script: Same Table Linked Records Backlinks

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

Explainer Video:

Base:

Code:

64 Replies 64

It looks like your code ends at line 8. You only copied and modified the configuration portion, which is useless without the rest of the code after it.

Jordan_Toplitzk
4 - Data Explorer
4 - Data Explorer

Thanks. that was it. much appreciated

Theo_Michel
6 - Interface Innovator
6 - Interface Innovator

Thanks for sharing @Paul_Warren! I understand now, although I have reservations about the fact that it runs the full table fixup on each change, but that probably isn’t actually such a big deal. I also would like to support multiple parents/children for each record.

To that end, I created a script that tries to automatically create backlinks based on the pattern that @Justin_Barrett suggested. (storing the previous version of the back/forward links and using them to calculate the diff after a change) I welcome any feedback y’all might have. : )

Antoine_Caffin
4 - Data Explorer
4 - Data Explorer

Hello @openside, this script is awesome!
I have a question about the Family relations graph that you are showing at 1:30 in the video:
how can I build this? I don’t find it in the apps…

Thanks for you help

openside
10 - Mercury
10 - Mercury

Thanks @Antoine_Caffin - I believe that is the “Org Chart” app

openside
10 - Mercury
10 - Mercury

actually - its the “Flow chart” app

thanks!
yes that’s the one…
not awesome to build a family tree, but it’s a start :slightly_smiling_face:
++

Sal_Ohcin
6 - Interface Innovator
6 - Interface Innovator

I am noticing that some of the records disappear when I Run the script. And then re-appear when I run the script again. Strange bug… not sure I understand why. Anyone come across this?

Im guessing you have a filter that is showing/hiding them based on the updates.

I don’t have an Airtable filter applied to that spreadsheet.
The table is setup to allow linking of multiple records… not sure if that is causing the problem.
I could try to share a screenshot if that’s helpful.

Admin_AFA
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi, thanks a lot for this useful script.
I tried to run it in an automation but it outputs an error: “TypeError: output.clear is not a function
at main on line 114”

The same script works fine as a block script.

How can I fix this please ?

Hi, yes, the output is only available in the script. If you remove all lines that start with output.

like: output.text(…), output.clear(…). output.markdown(…), etc

Steve_Milt
4 - Data Explorer
4 - Data Explorer

Thanks. This is excellent.

Brett_Snelgrove
6 - Interface Innovator
6 - Interface Innovator

Hi there and thanks for sharing @openside! Incredibly valuable solution.

My question is, if you are working in a dynamic scenario where a linked relationship could be unlinked from one end, is there a way to run a version of this script to check for this and do the reverse and remove links?

Thanks in advance!

openside
10 - Mercury
10 - Mercury

Hi @Brett_Snelgrove - I don’t have plans to modify the script, maybe someone else can run with that idea. It does get tricky trying to keep both ways working and in sync, probably why Airtable never implemented it. Sorry can’t be of more help this time around.

Anjan
4 - Data Explorer
4 - Data Explorer

Hello @openside . Thanks for this script. Very useful.

I am just using it in a scripting block. No fancy automation. When using this script, I have noticed a limitation / bug which I would like to confirm with you. It does not look like anybody else has pointed this out, so I may be mistaken here:

The script does not remove the last backlink in a cell of the destination column. Let me explain with an example. Consider three records:

ID		|		Predecessor ID	|	Successor ID
1		|						|	2, 3
2		|		1				|	3
3		|		1, 2			|

If I remove “1” from the “Predecessor ID” column of record number 2, and if I then run the script, the “Successor ID” column of record 1 gets updated correctly. It ends up with just the value “3” in that column.

If I remove the “2” from the “Predecessor ID” column of record number 3, and if I then run the script, the “3” does not get removed from the “Successor ID” column of record number 2.

Looking at the code, I saw that the reason for this behaviour could be because a “destination” cell is touched ONLY if it has been mentioned somewhere in the source column of any record. If a destination cell has not been mentioned, then its value does not get updated at all.

Is this a known issue? Do you have any quick way to fix this? Would it work to just (programmatically) delete the entire column’s values at the start of the script?

I made the following change, which worked. After line 78, I added the following line:

if (!tree[rec.id]) tree[rec.id] = []

But this obviously increases the running time of the script tremendously.

Manually, I know that I can just click on the column header to select the entire column and then press the delete key to clear the column instantly. What is the syntax to do this programmatically?

openside
10 - Mercury
10 - Mercury

@Anjan - I haven’t tested this, but try the updated code: Same Table Backlinks · GitHub

I expanded on your change to check all and update if there were some remaining that need to be cleared, and ignore if it was already empty, so should reduce the time running.

Let me know if it works.

Hannah_Wilson
4 - Data Explorer
4 - Data Explorer

Disclaimer: I have the most rudimentary understanding of JS that it’s possible to have (but I’m trying to learn!)

Thank you for creating this script - it should do all I need to do, but I’m getting an error message as follows:

TypeError: null is not an object (evaluating ‘pRecord.getCellValue(dest).length’)
at asyncFunctionResume
at promiseReactionJob

Please can someone who understands what they’re doing help me to correct this!

You got TypeScript’d. Typing aside, null is not an object is a pretty strong indication that some part of the code is executing sooner than it was intended to. Making matters even more interesting is the fact that you’re dealing with a null value; this is significant because unlike undefined objects, anything js labels as null had to have been manually set to that nil-value by someone or something. The Monaco linter hasn’t given up any line numbers? Can you try copy-pasting the code into VSC? Ideally with all of the major js+ts plugins installed, the entire software suite is free.

Lindsay_Patross
6 - Interface Innovator
6 - Interface Innovator

I keep getting an error message when I try to run this script.

TypeError: Cannot read property 'length' of null
    at findChildren on line 92
    at async syncLinks on line 108
    at async main on line 116

I think I have everything configured correctly. Any suggestions on what to try next?