Help

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

Re: Copy code from Script Extension into 'script' block for automations

2204 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Elizabeth_Aucti
6 - Interface Innovator
6 - Interface Innovator

Hey there,

non-coder here...

I added extension "Create records for multiple templates". I hooked it up to run when a button is pressed. It is working correctly.

But I would prefer for it to run auto once conditions are met. I know this can be done in automations with a scripting block. My question is - can I just copy and paste code from the extension into a scripting block for automation?

Screen Shot 2022-12-02 at 8.19.53 AM.png

I tried, but I am seeing a lot of red. I assume I am misunderstanding the foundation of the code, or I am missing a step? Would adding something in the input variables to make this work?

Screen Shot 2022-12-02 at 8.26.51 AM.png

Screen Shot 2022-12-02 at 8.28.11 AM.png

2 Replies 2

Generally speaking, moving a script from a Scripting Extension to a Run a Script action within an automation is rarely a simple copy and paste.

The Scripting Extension has several input and output commands designed to ask a user a question or show a user something. Since the Run a Script action is autonomous, there is no need for the vast majority of those inputs/outputs and therefore none of them will work.

Rules of thumb when moving from the Scripting Extension to the Run a Script action step:

  • Any line that includes `input.something` needs to be replaced with either a hardcoded value, or an input variable. For instance, you likely would replace an `await input.recordAsync()` with an input variable that pulls in whatever record fired the automation.
    • `input.config()` works in both Extensions and Automations but the function expects very different values depending on which environment you're using. See API reference. The API will tell you what functions work in Extensions, which work in Automations, and which work in both.
    • There are no settings for an automation script. Replace each of your settings by simply declaring each variable. For example, tables would look something like `const parentTable = base.getTable("Name or ID of table")`. Refer to the Script API for declaring tables and for declaring views and fields.
  • Any line that includes `output.something` can be deleted. There is no "place" to output anything in an automation script.

If you have specific questions about a specific script, its best to give a link to that script since very few of us here in the forums have every published script memorized or bookmarked.

Elizabeth_Aucti
6 - Interface Innovator
6 - Interface Innovator

thanks very much for this, I appreciate the background. As suspected, I think it might be over my head and a bigger learning curve than I had hoped. Thank you for the feedback