A bit extended guide - on triggers and js_run_code


No row selected
No row selected
lobster40     2 years ago

Hello forum.For those who hate reading - you may check it via youtube link https://youtu.be/JO4t6pZlToo

Let me show an example how-to use triggers\event\js_code. 

Let suppose we have a task: I have two tables, one has project names and second has tasks for project. Each project has similar tasks and I need to populate them for particular project. Example is a bit synthetic, but it’s simple.

So my tables are:

I didn’t find any options to fill third table except by automated way.

I've read documentation few times – and didn’t find a pictures, thus I’m sharing it with you.

So it’s definitely automation, let start.

Overall way:

1 need to create a trigger

3 add automation to trigger

4 somehow bind trigger to input form.

Step by step:

1 Expand settings  ->Event- > Triggers and call “Add trigger”

  1. Any name
  2. WHEN – Never
  3. Action == blocks (or if you know NOW how to use js_code you may choose run_js_code)
  4. Safe a trigger. And return to all triggers.



Ok, time for “automation”.

5 Call “configure” for your just created  trigger and you will see some not overcomlictaed UI (Scracth has muuch more blocks, not sure if they all are usefull, but more:)))




workflows are simple: when I initiated trigger for particular raw in Project table, it some should copy all tasks from Task table to my third table with particular Project . So I need cycle, I need read a table and insert operation in table for each item in Tasks table

I spent a lot of time fighting with empty table as a result, my problems were in few areas:

  • I didn’t declare proper types
  • I was not able to convert query to list items.

After few iterations I fixed it all and you may see the algo as a picture bellow


And bigger picture




safe the changes and now time to find a way to call the trigger,

Open “views” -> create new -> give some name, default template “list” is fine, table – in my case “Project” -> configure

So you may see only one table in rectangle and have to add another with type: Action on raw – choose your trigger test_trigger in my example. Next -> Next-Safe


Now you returned to Views page and it’s time to run view – 3dots on right side and choose RUN


Now you see some record and button with trigger name


Press the button and check Project_tasks table.


So , automation is working and it’s time to be disappointed: blocks list is so por, I cannot work with serious math\dates\(whatever) ..

Yes that’s, there is no such block. But good news – you got a JS code entry example. Now it’s time to edit your trigger by “edit” button and choose run_js_code in Actions instead of blocks. Open the trigger – now it has code only and you may fix it as you wish (if you know js)


Have a good day

PS - you may convert blocks type to run_js_code, but you will loose your code on conversion form run_js_code to block.. be carefull:) 


No row selected
No row selected
lobster40      2 years ago

hmm, I was able to put only one picture,, that's bad

No row selected
No row selected
lobster40      2 years ago

and even one by one I was not able to insert them :(

No row selected
No row selected
lobster40      2 years ago

No row selected
No row selected
lobster40      2 years ago

that's dissapointing - I'd like to keep pcitures here instead of upload them to some place and inserting links here

Sign up to post a reply