Skip to main content

BlockChaining - Is it Possible?

  • March 3, 2020
  • 43 replies
  • 241 views

Show first post
This topic has been closed for replies.

43 replies

Forum|alt.badge.img+18

I’ll give it a shot then, when I’m not rolling the internet on my phone :winking_face:


Forum|alt.badge.img+18

I believe this is possible. Never checked into it, but I have often wondered if this approach wasn’t a pathway to extending the flight ceiling of Script Blocks by dynamically introducing code into a solution for which the code occupies no space (i.e., script memory per-se) in the lately-bound process. Note - you may have experienced a script block is unable to load more than about 2,000 lines of script and minifying seems to help.

My example makes it obvious that …

  1. Script fragments can exist in records/fields; a fragment is no different than a dynamic library
  2. Script in records/fields can be executed with eval()
  3. Return values from dynamically called script fragments can be persisted
  4. Processes that use multiple script fragments can be strung together and even reordered, filtered, and updated dynamically

It totally works!

Pasting the entire minified moment.js library into a script block is rejected for making the script too long. However, a long text field can hold the entire minified library:

And that library can be called into the Script block with eval(), as if you were importing it with import.

As you see from my screenshot above, you will clearly not have intellisense while editing, and any calls to the eval'd library will be flagged as errors, but once the library is eval'd its models can be used in the script.

Thank you for discovering this strategy, @Bill.French – this is going to make the Script block so much more flexible for junior scripters who prefer to lean on other people’s work :winking_face:


Forum|alt.badge.img+19
  • Author
  • Inspiring
  • June 28, 2020

It totally works!

Pasting the entire minified moment.js library into a script block is rejected for making the script too long. However, a long text field can hold the entire minified library:

And that library can be called into the Script block with eval(), as if you were importing it with import.

As you see from my screenshot above, you will clearly not have intellisense while editing, and any calls to the eval'd library will be flagged as errors, but once the library is eval'd its models can be used in the script.

Thank you for discovering this strategy, @Bill.French – this is going to make the Script block so much more flexible for junior scripters who prefer to lean on other people’s work :winking_face:


You’re welcome!

Yep - perfect use case for this feature looking for a problem to solve. :winking_face:

This will probably not be a big issue as libraries – for the most part – are well-tested and few will have the desire to modify them. But, this doesn’t stop any of us from using this approach for creating and managing our own reusable libraries in this way.

Sidebar - if Airtable is able to create a JSON editor for long text fields, it can certainly create and install a code editor for javascript because - wait for it - json is javascript. :winking_face:

Sidebar.2 - BTW, this happened when I envisioned a way to manage code as if it were data and what better example for doing so with the advantageous relationship that Script Blocks share with data tables?

Sidebar.3 - feel free to write the Show & Tell with a title that’s more aligned with what you are showing here; “BlockChaining” doesn’t really express what you’re accomplishing with libraries.

Sidebar.4 - no developer (me included) should ever be given credit for using eval() in creative or potentially dangerous ways. LOL


Forum|alt.badge.img+18
  • Inspiring
  • June 28, 2020

No one truly understands how eval() really works. :winking_face: Perhaps this will help.

This is the magic of eval(); it makes it possible to construct code in a very late binding process purely as a string and then execute that code AFTER the string has been fully constructed.


Many thanks @Bill.French !
It seems already to me to be the right link but I would ingest and process it during free hours !

Bill had already suggested this in this thread or elsewhere and there you tried, and succeeded! Bravo and thank you very much!
It’s time for me to go on vacation (soon) to try to give something to the Community in return, but for the moment, in javascript, I’m learning to play the Who and the Rolling Stones as perfectly as possible : I’m not composing anything original yet. But it will come !
oLπ


Forum|alt.badge.img+18
  • Inspiring
  • August 8, 2020

Your English is almost as good as some English people I’ve met and certainly better than some Americans. :slightly_smiling_face: And despite my last name, you do not want to hear a single utterance in French from me.

One of the design goals of this “sample/example” script was to determine how late script could be bound in a Script Block. That was my only objective in building this - I wanted to see and understand at an architectural level how abstract code could be made to run in a script block or even a custom block.

And, of course, the answer is that it may be bound extremely late - script “injection” into a running framework is entirely within the scope of apps built in Script Block and it demonstrates “just-in-time” application behaviours.

Using this approach, very large script “libraries” (perhaps not built in Airtable but certainly) managed in Airtable could be deployed to avoid the Script Block size ceiling. It also means that new scripts and script versions could be deployed without users copying and pasting into each their own blocks.

A secondary design goal was to see how well the vast benefits of tables could be used to create a smart system, or at least some simple wizards and surveys that compile answers.


Hi @Bill.French,

Subject to cross-checking with some of you, this ceiling is at 49999 characters including space :slightly_smiling_face:

Best,

olπ


Forum|alt.badge.img+18
  • Inspiring
  • October 16, 2020

You’re welcome!

Yep - perfect use case for this feature looking for a problem to solve. :winking_face:

This will probably not be a big issue as libraries – for the most part – are well-tested and few will have the desire to modify them. But, this doesn’t stop any of us from using this approach for creating and managing our own reusable libraries in this way.

Sidebar - if Airtable is able to create a JSON editor for long text fields, it can certainly create and install a code editor for javascript because - wait for it - json is javascript. :winking_face:

Sidebar.2 - BTW, this happened when I envisioned a way to manage code as if it were data and what better example for doing so with the advantageous relationship that Script Blocks share with data tables?

Sidebar.3 - feel free to write the Show & Tell with a title that’s more aligned with what you are showing here; “BlockChaining” doesn’t really express what you’re accomplishing with libraries.

Sidebar.4 - no developer (me included) should ever be given credit for using eval() in creative or potentially dangerous ways. LOL


Did anyone write this show and tell article? I would love to dive deeper into the inclusion of libraries into JS. This entire article is an incredible example of your superhero status Bill!


Forum|alt.badge.img+19
  • Author
  • Inspiring
  • October 16, 2020

Did anyone write this show and tell article? I would love to dive deeper into the inclusion of libraries into JS. This entire article is an incredible example of your superhero status Bill!


Not that I’m aware of one. And unfortunately, that approach won’t work in automation scripts as eval() apparently isn’t supported in that scripting feature as pointed out recently by @kuovonne.

To be clear, I’m not sure its wise for anyone to follow me off the cliff in a Thelma & Louise journey to use tables as script libraries despite the fact that @Jeremy_Oglesby found the concept somewhat compelling in a script block context.

And to ensure there’s no misunderstanding about my original intent - this approach was created to achieve one thing - to provide dynamically changing script logic while the script was running. This objective is a close cousin of the late-binding of libraries.

Setting aside library inclusion, Airtable should make it possible (in all script environments) to manage code in much the way all JavaScript developers do this - by establishing a model for reusable chunks.

I really appreciate the kind comments, but I must warn you - it didn’t end well for Thelma & Louise. There’s a fine line between superheros and super-nut-jobs.


Forum|alt.badge.img+19
  • Inspiring
  • October 16, 2020

Bill just needs to find his Ted to go on his Thelma & Louise adventure :slightly_smiling_face:

We developed an alternative approach we use at Openside/On2Air that allows for reusable snippets/libraries and better overall management of your scripts.

Check out the product here: https://on2air.com/on2air-scripts

Here is a video review of how it works:


Forum|alt.badge.img+18
  • Inspiring
  • October 16, 2020

Bill just needs to find his Ted to go on his Thelma & Louise adventure :slightly_smiling_face:

We developed an alternative approach we use at Openside/On2Air that allows for reusable snippets/libraries and better overall management of your scripts.

Check out the product here: https://on2air.com/on2air-scripts

Here is a video review of how it works:


Hello Openside,your solution is really well designed, I think, but after paying for my Airtable-Pro-Plan, I had a careful compromise to make between several Third-Part-Solutions that offer different additional tools to Airtable without being able to pay them all for my current low to minimal traffic.
I wish you all the best for your offer of excellent Add-Ons for airtable.
oLπ


Forum|alt.badge.img+18
  • Inspiring
  • October 16, 2020

Not that I’m aware of one. And unfortunately, that approach won’t work in automation scripts as eval() apparently isn’t supported in that scripting feature as pointed out recently by @kuovonne.

To be clear, I’m not sure its wise for anyone to follow me off the cliff in a Thelma & Louise journey to use tables as script libraries despite the fact that @Jeremy_Oglesby found the concept somewhat compelling in a script block context.

And to ensure there’s no misunderstanding about my original intent - this approach was created to achieve one thing - to provide dynamically changing script logic while the script was running. This objective is a close cousin of the late-binding of libraries.

Setting aside library inclusion, Airtable should make it possible (in all script environments) to manage code in much the way all JavaScript developers do this - by establishing a model for reusable chunks.

I really appreciate the kind comments, but I must warn you - it didn’t end well for Thelma & Louise. There’s a fine line between superheros and super-nut-jobs.


Airtable is not only a very important business tool that must be based on reliable, stable, consistent techniques and must meet the selection criteria of market decision-makers, as @Bill.French teaches us in some of its writings.
It’s also a dream tool that I’ve been waiting for a long time when I found it in a corner of the WEB for a “small lab” that started with Z80s and that today enjoys “As A Service”, “Serverless”, “Micro-Applications”, “Micro-Front-Ends” so don’t hesitate to play Thelma & Louise again from time to time: there is a Audience that loves to follow you on these roads too!

oLπ


  • Inspiring
  • June 3, 2021

Airtable is not only a very important business tool that must be based on reliable, stable, consistent techniques and must meet the selection criteria of market decision-makers, as @Bill.French teaches us in some of its writings.
It’s also a dream tool that I’ve been waiting for a long time when I found it in a corner of the WEB for a “small lab” that started with Z80s and that today enjoys “As A Service”, “Serverless”, “Micro-Applications”, “Micro-Front-Ends” so don’t hesitate to play Thelma & Louise again from time to time: there is a Audience that loves to follow you on these roads too!

oLπ


So I am looking at this solution for Airtable automation since it would mean you could store global functions in a separate table and reference them across your automations.

However, inside Automations I am getting the error “ReferenceError: eval is not defined” despite ‘eval’ showing up as a usable function in the tooltip.

Any ideas? Any workarounds here?


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • June 3, 2021

There are a few small differences between running a script from scripting app with a button and running a script as an automation. The inability to use eval in an automation is one of them. Some other differences include using setTimeout and how fetch works.


  • Inspiring
  • June 7, 2021

There are a few small differences between running a script from scripting app with a button and running a script as an automation. The inability to use eval in an automation is one of them. Some other differences include using setTimeout and how fetch works.


Hmm is there a workaround? It’d be great to put global functions into a table that can be referenced directly as code.


Dominik_Bosnjak
Forum|alt.badge.img+17

A CDN + JSON.parse()? But building anything on this sort of functionality seems… unwise.


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • June 9, 2021

A CDN + JSON.parse()? But building anything on this sort of functionality seems… unwise.


JSON.parse() won’t return an executable function. You could store the code as a string in the JSON, but then you would still need eval to convert the string into an executable function.


Dominik_Bosnjak
Forum|alt.badge.img+17

JSON.parse() won’t return an executable function. You could store the code as a string in the JSON, but then you would still need eval to convert the string into an executable function.


Ah, I learn something new every day, cheers.


Forum|alt.badge.img+2
  • Participating Frequently
  • July 13, 2021

I just got Pro and… it’s so powerful, should have gotten it sooner!

I think this is totally possible with Automations / Webhooks — on each Webhook, the last action you run is a script that could fetch another webhook in another base/table… debugging this thing sounds like a nightmare though.

Basically:

  1. Incoming trigger (e.g. a form is filled)
  2. Automate based on trigger — run a script that calls a webhook
  3. Webhook triggers actions in another base/table (e.g. create a row), and a script that fetches more webhooks
  4. Rinse and repeat until done

ScottWorld
Forum|alt.badge.img+35
  • Genius
  • August 6, 2023

This could be done with Airtable’s webhooks, but Airtable’s automation webhooks come with their own set of limitations. Even the webhooks API has significant limitations, such as a limit of 10 webhooks per base.

Even though Make is a low-code environment (instead of a scripting environment), this is one of the Top 20 Reasons why I encourage Airtable users to take a look at Make for their automations.

Not only does Make have more advanced webhooks than Airtable with no limitations (along with custom webhook responses and even mailhooks), but blockchaining is possible with Make and reusable “code” is possible in Make.

Make allows you to copy and paste modules from one scenario to another, Make allows you to export and import blueprints for backups or portability to other accounts, and best of all, you can use Make’s own internal meta modules to daisychain scenarios together with custom variables. There are 44 meta modules that let you control Make, including running other scenarios with dynamic variables.

There is a small learning curve with Make, which is why I created this basic navigation video to help. I also provide the links to a few other Make training resources. For example, to instantly trigger your Make scenarios from Airtable, check out this thread.