Finding and replacing certain text within project template task names

We are currently using Zapier to automatically find/replace certain task names, after a new project gets created with an Asana Project Template.

Screenshots:

Basically, we have a Website Project Template, with a lot of the tasks having sitename.com in front of them. When a new project gets created from this template (which is a step in the Zap), we are then wanting to replace any instance of sitename.com in the task names with the name of the project itself (which is usually a website domain).

For example, the new Project (from the template) will be called acmeproducts.com — and thus the tasks will be updated to swap out sitename.com with acmeproducts.com. That way, we can end up with tasks such as:

  • acmeproducts.com - Mockups
  • acmeproducts.com - Initial Build
  • acmeproducts.com - Rev 1
  • etc.

Currently this is working with Zapier, but its eating up lot of steps/actions, because we’re using the built-in Zap actions of “Find Task in Project” and then another action of “Update Task”. And any time we add a new task to the template that we want to follow that naming convention, we then have to update the Zap with 2 additional actions (the FIND and the REPLACE). This is currently eating up about 20 actions in the Zaps, and makes it cumbersome on future changes.

Long story short, does anyone know of either:

  1. A way to add a merge syntax to the Asana Template, so that it will automatically swap in the project name during creation? E.g., {project_name} could be used by Asana to automatically swap that in when the new project is created by the https://app.asana.com/api/1.0/project_templates/xxxx/instantiateProject API.
  2. A way to not use a separate Zapier action for each find/replace, and instead create a Javascript Code action that will use the Asana API to automatically look up an instances of sitename.com (or any other designation) and swap it with the project name? I figure it’d be easier to have a single complex chunk of JS code, rather than a separate action for each task name.

@FreshyJon - afaik, your first question is currently not possible (this is a great idea though). I think the project instantiation endpoint really only has the limited data inputs that are listed in the dev docs.

For your second question, I’m not particularly well-versed in Zapier (I’ve used Make before instead), but you would presumably need to iterate over all tasks in the newly instantiated project, search for a regex, and then update the task name wherever that regex is found. That act of updating the task presumably counts as an action, and I don’t know of a way to avoid calling that endpoint for each task you want to change the title on (hoping someone who regularly uses Zapier can confirm/correct).

Does your org host your own code anywhere (any function-as-a-service provider)? The script to do this would be pretty simple to write and could probably be done by a non-dev if you have the infrastructure already.

Hey @Stephen_Li , basically within Zapier, we can use JS code as an action, so theoretically I’d hope there was a way to create a chunk of code that would do as you describe via the Asana API and additional scripting to do the find/replace, etc.

Essentially a script that says “Look within this Project ID and find any parent task with sitename.com in the task name. Update each of the found tasks by replacing sitename.com with the name of the project.”

Sounds simple. I just don’t know how to write it. :slight_smile: Is there a spot on the forums for such requests, that I could throw a few bucks at?

FWIW, if unsure of how to write scripts for use in Zapier, here is an example of one I did that works fine (unrelated to this current request): Asana API + Zapier | Duplicate a task via API · GitHub

Ah, ok that makes sense. If you’re able to actually make API calls in that custom JS code and count it all as a single action, I think the approach would be:

  1. Instantiate project from template (1 action), returns project object including gid
  2. Call getTasksFromProject with newly created project GID (1 action), returns array of tasks (I think)
  3. Custom js block (1 action)
    a. Iterate over data from step 2, use string.replace to try replacing sitename with target value (if sitename is not found, original string is returned) and then call updateTask with only the name in the body’s data object

I think it’s a pretty simple script, so you honestly might be able to write it yourself since you seem to have technical chops. Theoretically, you could maybe combine this all into one custom js block if you’re comfortable with handling promises and assuming Zapier allows you to call APIs from within the custom block (seems like they do based on your example). One note: I don’t think subtasks get pulled in the getTasksFromProject call, so something to be aware about handling.

Sorry, I’m not too familiar with who in the forum does custom code consulting, but hope someone can help out! I presume this dev/api area is the right place to get eyes on it.

This is the place!

Here are a few possibilities to get the ball rolling:
@Bastien_Siebman @Bryan_TeamKickstart

1 Like

@FreshyJon and @Stephen_Li, I’d recommend one of 2 options:

  1. If you are wanting to stick with using the API or Zapier, I’d recommend using the Search Tasks in a Workspace endpoint (Search tasks in a workspace) instead of get tasks from project so that you are only pulling the results that meet the specific naming criteria instead of sometimes wasting Zap steps on tasks that don’t need name adjustments. Use fewer ops/steps that way.

  2. Alternatively, my team built a free add-on called Supersana.io that could help with this. Currently we have a feature to “Add task prefix or task suffix”, which is obviously not what you are wanting. But, we are adding “Find and Replace” to that feature set soon (currently slated to be done by March 8th or sooner). Initially, it will come out as a manual button to push to “Find and Replace” across a whole section or a whole project. Later in the year, we’ll be rolling out the ability to set it as an ongoing automation. Anyway, so the point is, beginning around March 8th, Supersana.io will allow you to bulk Find and Replace. Later in the year, it’ll allow you to set that automation to run on an ongoing basis for a project.

For now, the closest solution to your entire issue is to use Zapier or the API directly, but I do recommend the Search Tasks endpoint, and not get tasks from project.

My two cents.

1 Like

@Bryan_TeamKickstart - ah brilliant, makes total sense.

@Bryan_TeamKickstart are you open/able to assisting with the writing of the script for Zapier to use?

I like the idea of the Search tasks in Workspace, since you could then limit that to the desired new project ID. Although, the text string mentions it “performs full-text search on both task name and description”. Would there be a way to limit to just the task name?

Regarding your Supersana.io, it sounds interesting if it weren’t a manual button to do so. Even an “ongoing automation” wouldn’t really fit the exact use-case here. We basically just want it to run one-time, upon the creation of the Project from the template.

@FreshyJon - Yes, we could help you. We do Asana implementations and integrations/automations for hire.

To answer your question, there is not currently a way to limit the API call to JUST the task name, however, we will simply add a filter in the Zap so that it only processes and continues the automation if the task name is an exact match.

To discuss exact specs so that we understand precisely what you want it to do, please book a 15-min quick-help call. Grab a free 15-min meeting here: kstart.io/quick-help

Then you can take the details and do it yourself, or we can build it for you.

1 Like