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:
- A form asking “which shows will you be exhibiting at?”
- When a brand selects a show, their name should automatically appear in that show’s “Brands Represented” field
- This needed to work seamlessly without manual data entry
- 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:
- Reads a brand name from a text field
- Checks if that brand exists as an option in a dropdown field
- Creates the option if it doesn’t exist
- 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:
-
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!
-
Iterative Refinement: Multiple rounds of AI-assisted debugging and improvement
-
Professional Polish: Developer Timeth provided final optimization and error handling
-
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!
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(
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
- Validate email addresses using regular expressions
- Standardize data entry formats
- Enforce business rules on form submissions
Advanced Task Management
- Add comments to parent tasks when subtasks are updated
- Move parent tasks based on approval status
- Assign owners across related tasks based on custom field values
- Automatically balance workload by assigning tasks to team members with the least current assignments
Goal and Progress Tracking
- Update goal metrics based on custom field values when tasks are completed
- Update custom fields on projects within portfolios based on task completion
Complex Workflow Automation
- Create new tasks in other projects and link them as subtasks
- Delete all subtasks when certain field values are selected
- 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
- Asana Enterprise or Enterprise+ subscription
- Project editor or project admin permissions
- Node.js installed for local testing (optional but recommended)
Step-by-Step Setup
- Enable Script Actions in Your Project
- Navigate to any project in your workspace
- Click Customize > Rules > Create custom rule
- This will prompt you to install the “Scripts by Asana” app if not already installed
- Create Your First Script Rule
- In the rule builder, select your trigger (When…)
- Navigate to the External actions tab
- Select Run script
- The script editor will open
- Local Development Setup (Recommended)
- Create a new directory for script development
- Run
npm install asana
to install the node-asana client library - Create your script file (e.g.,
automation-script.js
) - 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()
-
Testing and Deployment
-
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!) -
Copy and paste your tested script into the Asana script editor
-
Remove the Personal Access Token line (authentication is handled automatically in production)
-
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:
- Scripts can currently only interact with the Asana API (external API calls aren’t yet supported)
- Scripts cannot yet be used within project templates or bundles
- 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.