Getting a list of project IDs of a given task

I am currently using Zapier to log edited task data into a Google Sheet. The Zap triggers if/when a task is edited within a particular project.

Within Zapier, it’s easy to get the task’s ID and other field data. It’s also technically possible to get a list of project IDs that it belongs to as well. Screenshot: https://i.imgur.com/ZcDgDHx.png

I’m using the Zapier “Code” action to output a list of those IDs. Screenshot: https://i.imgur.com/EWNC7zF.png

How would I update my Javascript code so that I can omit certain project IDs from being interested in. For example, I only want one of those 4 project IDs. The way we use Asana with this particular Zap, we won’t always know what the project ID is that I want, but I would like to supply a list of Project IDs that I know I DON’T want.

Basically, these Asana tasks would be in 4 different projects. I will always know the ID of 3 of those projects, and thus would like to omit those from the output. This will help me find and log the project ID of the new project that I’m looking for.

Within that Javascript code, how could I supply a list of Project IDs to omit from any output?

For example, if the project IDs that the task is within is:

  • 999,555,123,888

How would I supply a list of the “known” IDs of 999,555,888 so that only 123 (the ID I won’t ever know) is the only one that is output within that code?

Sorry if this is confusing. Basically I just want to output all Project IDs of this edited task, that don’t match the ones that I supply in this code. In most cases, it should therefore only output 1 project ID.

Hi,

You should be able to store the ones you don’t want in a string array in Javascript, and then filter your list of projects to keep only those which don’t match.

1 Like

Thanks for pointing me in the right direction. Would you by chance be able to provide example code to assist in this endeavor?

1 Like

Not really, I don’t have the code myself. It is pretty hard to code in Zapier, you should build yourself a small javascript file and run it yourself. Once happy with the result, you can’t paste into Zapier.

I could code it for you if you are stuck.