Getting GID of duplicated Asana project via API

I am using Zapier to duplicate an Asana project based on certain conditions. In fact, when a certain task (in another project) is updated to be in a new “section”, it triggers my Zap. Let’s call this the Trigger Task.

The Zap then has some Javascript that runs to duplicate an Aasna project template that we created.

Here is that code/setup: https://i.imgur.com/fEvDTHX.png

I’d like to add a new action to this Zap, that will then move the Trigger Task into this new project (that was just created/duplicated).

I know I can use the “Add a project to a task” aspect of the API, here: Add a project to a task

But how do I get the GID of the newly created project?

In order to add this new project to the Trigger Task, I need to know the GID of the new project.

I assume there is a way for me to update my Javascript, so that I can capture the GID of the newly created project after it’s been built? How would I get the GID for the response, and then store that as a value that I can use within another Zap action?

Hi @FreshyJon,

When you submit the project-duplication request, you’ll get back the gid of a job.

What you then do is query the jobs endpoint periodically (like every few seconds) to get the details of the job, and each time, check the returned status property. Once you see a value of “succeeded”, that means the duplication has finished and you then grab the returned new_project.gid property and that will be the gid of the newly-created project.

1 Like

Thanks for that info @Phil_Seeman. Would you be available to supply code to assist in those steps, based on my current Zap and Javascript for the initial duplication?

Sorry, I’m afraid I’m a C# guy, not well versed in Javascript.