Unlocking Advanced Automation: How Script Actions Bridge the Gap Between Simple Rules and Complex Workflows

Have you ever found yourself wishing Asana’s automation could handle more complex scenarios? While standard rules are powerful for basic workflows, sometimes you need something more sophisticated. That’s where Script Actions come in – a game-changing feature that brings the full power of custom code to your Asana automations.

A Real-World Success Story

Recently, Felicity- a fellow Asana Ambassador - faced a complex challenge: managing trade show participation across multiple brands and events. The goal was simple in concept but tricky in execution – create an Asana form where brands could select which trade shows they’d be exhibiting at, then automatically populate those brand names in the appropriate show fields, if they selected other Felicity wanted the option to be able to automatically add to the multi-select.

Here’s what they needed:

  1. A form asking “which shows will you be exhibiting at?”
  2. When a brand selects a show, their name should automatically appear in that show’s “Brands Represented” field
  3. This needed to work seamlessly without manual data entry
  4. If they chose “other” and free text entered, they wanted the option to be easily added to an enum multi-select field.

Standard Asana rules couldn’t handle this level of dynamic field manipulation. But with Script Actions, what seemed impossible became not just possible, but elegant.

The Script Actions Solution

The solution involved creating a custom script that:

  1. Reads a brand name from a text field
  2. Checks if that brand exists as an option in a dropdown field
  3. Creates the option if it doesn’t exist
  4. Adds the brand to the multi-select field

I took on the challenge - and using AI i worked to prototype up a script, and then a big thanks to Timeth here at Taco Technologies for helping get it over the line!

The AI-Assisted Development Process

My experience demonstrates how AI tools can accelerate Script Actions development:

  1. Initial Prototyping: Used AI (LLM) to generate the basic script structure and logic, I know enough about reading an API and a deep understanding of Asana to know what we were after!

  2. Iterative Refinement: Multiple rounds of AI-assisted debugging and improvement

  3. Professional Polish: Developer Timeth provided final optimization and error handling

  4. Knowledge Transfer: The process helped bridge the gap between business requirements and technical implementation

Benefits of AI-Assisted Development

  • Reduced Developer Time: Cut down on development team resource requirements

  • Better Requirements Writing: Helped translate business needs into technical specifications

  • Rapid Prototyping: Quickly generated working code for testing and validation

  • Learning Tool: Enabled non-developers to understand and contribute to automation solutions

For my test environment I chose Supermarkets, but this is applicable to many different use cases!

Script in action

Here’s the complete working script:

Summary

Preformatted textconst SOURCE_CUSTOM_FIELD_GID = '12***********13'; // Shop Name const TARGET_ENUM_FIELD_GID = '12**********53'; // Shops Field async function run() { log("task gid" + task_gid) const taskGID = task_gid; // Step 1: Fetch task details const taskData = await tasksApiInstance.getTask(task_gid, { opt_fields: 'custom_fields' }); if(taskData){ log("fetching task details was successfull" + taskData.data.gid) }else{ log("fetching task details failed" + Json.stringify(taskData)) return; } const customFields = taskData.data.custom_fields; if (!customFields) throw new Error('Task has no custom fields'); const sourceField = customFields.find(f => f.gid === SOURCE_CUSTOM_FIELD_GID); if (!sourceField) throw new Error(Source field GID ${SOURCE_CUSTOM_FIELD_GID} not found on task); const sourceValue = sourceField.text_value; if (!sourceValue) throw new Error('Shop Name field is empty on the task'); // Step 2: Get enum options for target field const enumData = await customFieldsApiInstance.getCustomField(TARGET_ENUM_FIELD_GID ,{opt_fields:'enum_options'}); if(enumData){ log("fetching task details was successfull" + enumData.data.gid) }else{ log("fetching task details failed" + Json.stringify(enumData)) return; } let enumOptions = enumData.data.enum_options; if (!Array.isArray(enumOptions)) throw new Error('Enum options not returned correctly'); // Step 3: Create option if not found let option = enumOptions.find(opt => opt.name === sourceValue); if (!option) { log("creating enum " + sourceValue) const createData = await customFieldsApiInstance.createEnumOptionForCustomField( TARGET_ENUM_FIELD_GID, { body: { data: { name: sourceValue }} }); if (!createData) { log("Creating enum value failed"); return; }else{ log("created enum option") } option = createData.data; } // Step 4: Update task with new enum value const targetField = customFields.find(f => f.gid === TARGET_ENUM_FIELD_GID); const currentValues = targetField?.multi_enum_values?.map(v => v.gid) || []; const updatedValues = currentValues.includes(option.gid) ? currentValues : [...currentValues, option.gid]; const updateData = await tasksApiInstance.updateTask({ data: { custom_fields: { [TARGET_ENUM_FIELD_GID]: updatedValues } } }, task_gid); log("updated task" ) if (!updateData) log("Updating task failed"); // Force a log so we see success too log(:white_check_mark: Successfully added “${sourceValue}” to VS Shops Field); } run()

Breaking Down the Magic

Let’s walk through what this script accomplishes:

Step 1: Configuration and Setup

The script starts by defining the source and target custom field GIDs – unique identifiers that tell Asana exactly which fields to work with.

Step 2: Fetch Task Data

Using Asana’s API, the script retrieves the current task’s custom field values, specifically looking for the brand name in the source field.

Step 3: Check Existing Options

The script examines the target dropdown field to see if the brand name already exists as an option.

Step 4: Create New Option (if needed)

If the brand name doesn’t exist as a dropdown option, the script creates it automatically using Asana’s API.

Step 5: Update the Task

Finally, the script adds the brand to the multi-select field, preserving any existing selections.

What Makes Script Actions Special?

Script Actions represent a significant leap forward in Asana automation capabilities. Here’s why they’re game-changing:

Serverless Execution

No need to manage infrastructure or worry about hosting. Your scripts run in Asana’s secure, serverless environment.

Full API Access

Unlike standard rules that are limited to predefined actions, Script Actions give you access to the complete Asana API, opening up virtually unlimited possibilities.

Cost-Effective Automation

While AI-based rules consume credits, Script Actions are independent of credit usage and can run as often as needed.

Seamless Integration

Scripts integrate perfectly with Asana’s existing rule system, triggering based on the same conditions you’re already familiar with.

Beyond Trade Shows: Endless Possibilities

The trade show example is just the beginning. Script Actions can handle a wide variety of complex scenarios:

Form and Data Validation

  1. Validate email addresses using regular expressions
  2. Standardize data entry formats
  3. Enforce business rules on form submissions

Advanced Task Management

  1. Add comments to parent tasks when subtasks are updated
  2. Move parent tasks based on approval status
  3. Assign owners across related tasks based on custom field values
  4. Automatically balance workload by assigning tasks to team members with the least current assignments

Goal and Progress Tracking

  1. Update goal metrics based on custom field values when tasks are completed
  2. Update custom fields on projects within portfolios based on task completion

Complex Workflow Automation

  1. Create new tasks in other projects and link them as subtasks
  2. Delete all subtasks when certain field values are selected
  3. Inherit custom field values from parent tasks to subtasks

Getting Started with Script Actions

Ready to dive in? Here’s how to set up your first Script Action:

Prerequisites

  1. Asana Enterprise or Enterprise+ subscription
  2. Project editor or project admin permissions
  3. Node.js installed for local testing (optional but recommended)

Step-by-Step Setup

  1. Enable Script Actions in Your Project
  2. Navigate to any project in your workspace
  3. Click Customize > Rules > Create custom rule
  4. This will prompt you to install the “Scripts by Asana” app if not already installed
  5. Create Your First Script Rule
  6. In the rule builder, select your trigger (When…)
  7. Navigate to the External actions tab
  8. Select Run script
  9. The script editor will open
  10. Local Development Setup (Recommended)
  11. Create a new directory for script development
  12. Run npm install asana to install the node-asana client library
  13. Create your script file (e.g., automation-script.js)
  14. Development TemplateUse this template we put together to get started:
Summary

/** * Getting started * 1. Make sure you have node and npm installed, * 2. run npm i Asana to install asana api client * 3. create a new script file .js (eg: update_custom_field.js) * 4. write the relevant logic inside the run() function * 5. test it by running node <script file name> eg ‘node update_custom_field.js’ */ const Asana = require(‘asana’); let client = Asana.ApiClient.instance; let token = client.authentications[‘token’]; // TODO: Replace <YOUR_PERSONAL_ACCESS_TOKEN> with your Personal Access Token (PAT) // NOTE: This is only used for testing your script locally token.accessToken = “<YOUR_PERSONAL_ACCESS_TOKEN>”; // The following variables will be available in the script without setting them and // usually they are the ones belongs to the task/project the rule runs on const task_gid = “” // const project_gid = “” // const workspace_gid = “” // Add the required asana api instances let tasksApiInstance = new Asana.TasksApi(); let customFieldsApiInstance = new Asana.CustomFieldsApi(); // Asana exposes console.log() as log() these logs will be available when you go to the Run history and select the specific run // The logs are truncated to 5000 characters so make sure you only log whats needed. const log = console.log; // ------- From here onwards needs to go to the asana script async function run() { // The logic goes in here, add any reusable logic as separate functions, asana have a 10,000 character limit for the scripts } run()

  1. Testing and Deployment

  2. Test your script locally: node yourScriptName.js (optional - I struggled with VS Code, but it was a fun Sunday with a margarita in hand learning!)

  3. Copy and paste your tested script into the Asana script editor

  4. Remove the Personal Access Token line (authentication is handled automatically in production)

  5. Save and test your rule

Best Practices and Considerations

Programming Defensively

Always assume that custom field definitions may change. Your scripts should validate field types and handle unexpected scenarios gracefully.

Error Handling and Logging

Implement comprehensive error handling and use meaningful log messages to help with debugging.

Keep It Focused

Scripts have a 100,000 character limit, so keep your code focused and modular.

Test Thoroughly

Always test scripts locally before deploying to production environments.

Current Limitations and Future Potential

While Script Actions are incredibly powerful, there are some current limitations to be aware of:

  1. Scripts can currently only interact with the Asana API (external API calls aren’t yet supported)
  2. Scripts cannot yet be used within project templates or bundles
  3. Character limit of 100,000 characters per script

However, these limitations are likely temporary. Asana has indicated openness to expanding capabilities based on user feedback and demand.

The Bottom Line

Script Actions represent a fundamental shift in what’s possible with Asana automation. They bridge the gap between simple rule-based automation and complex, custom-coded solutions – all without requiring you to manage external infrastructure or worry about hosting.

Whether you’re managing trade shows, coordinating complex approval workflows, or automating data validation, Script Actions provide the flexibility and power to handle scenarios that were previously impossible with standard rules.

The trade show automation example shows how a seemingly complex business requirement can be elegantly solved with a focused script. More importantly, it demonstrates how modern development approaches – including AI assistance – can make custom automation accessible to a broader range of users.

Ready to unlock the full potential of your Asana workflows? Script Actions might just be the key you’ve been looking for.


Script Actions are available to Enterprise and Enterprise+ customers. Users need project editor or project admin permissions to create and manage scripts. Super Admins can control access to the “Scripts by Asana” app through the admin console.

6 Likes

Exemplary post in all respects, @Jonathan_Milne!

Script Actions dramatically expand Asana’s capabilities across the board and offer a solution for many of the product requests we see here in the Forum.

Thanks for this helpful, thorough contribution,

Larry

1 Like

Awesome post! We’ve been using script actions for a few months, and they’ve solved almost every limitation we were facing—and even opened up new use cases for us. One thing I’d add is the limitation of the 60-second timeout.

1 Like

Hi @Jonathan_Milne , excellent post! :clap:

Just one point, my devs actually ran into this last week and I’ve been meaning to cross-check; the limitation they faced was actually 50k characters.

Did you manage to surpass 50k?

1 Like

Hey Richard, thanks for the feedback! Not personally no! If we have a customer requiring something complex that would run over a single page with a script we have generally just built is directly into our cloud platform. The 100k limit is just pulled from the documentation - but each line creates tech debt that someone needs to pay! So keeping things short is def better! Your comment also got me thinking about Asana’s own API rate limits, I guess 50k lines would probably start to run into rate limits.

1 Like

Simple solution to character counts: just never comment anything :rofl: (I kid, absolutely comment everything)

In all seriousness, script actions are a gamechanger but my main issue (haven’t written a new one in the last month or two) was the timeout (I think it was either 30 or 60s); anyone know if that’s still in place and if people are having any issues with that? I mostly noticed it when I was trying to get one task to make wholesale changes to multiple other tasks/projects/portfolios/etc. since that involved hitting multiple resources (even when I ran them concurrently, I still noticed some instability and other timeout issues)

2 Likes