A new API for Project Templates

Thankyou for the advice Phil. As far as i am aware, I have defined the ‘anchor’ date, but am still getting an error saying that a field is missing.

Have you successfully been able to use this API function?

Hi @Sam_Lintern,

So this is a little more complicated than I thought.

Try putting “1” (the numeral 1 in quotes) for the value of the requested_dates gid and let me know if that works. If so, I’ll explain further.

That has worked, ThankYOU, Phil.

Yes, can you please clarify why it needed the “1” . I’m keen to learn from this.

So here’s the scoop…

When a project template is created and it contains tasks with relative dates, it also gets an element stored as part of its definition called requested_dates. You can see the specification for that element in the API docs:

This element defines what the “anchor date” should be when creating a project from the template.

When a project template is created in the Asana web UI and it includes relative dates, this element is selected by the user in the UI:

You can see what this element looks like in the project template object via the GET /project_templates/{project_template_gid} endpoint:

OK, so now you have a project template defined.

Now, when you want to instantiate a project from the template (and it contains tasks with relative dates), you have to provide it with the calendar date to use for that “anchor date”. You do that via the requested_dates element, just like you included in your instantiate_project request. Except that you have to give it the id that matches the requested_dates element in the template’s definition, in this case, “1”. In my testing, Asana currently always assigns that element a “1”.

Now you might ask, “why do I have to give it an id when there is only one requested_dates element in the template definition?”

I can’t go into too much detail in answering that question without violating my NDA with Asana, but let’s just say that in the future, there might be more than one requested_dates element in a template definition. Let’s say there are two, with ids of “1” and “2”. Now when you instantiate a project from that template, you’ll have to provide two calendar dates - and you’ll have to include an id of “1” with the first date and “2” with the second one, so that Asana knows which of your calendar dates to use for each of those two defined relative dates in the template definition.

Hopefully the above makes sense but let me know if not!

EDIT:
Another way I just thought of to explain it is to say that in the template definition, you’re defining a variable, and when you instantiate that template, you have to provide a value for that variable. The “id” is the variable name. Currently a template can only contain one variable, with an id/name of “1”; but imagine that, in the future, templates will be able to define multiple variables, each with a unique id/name; and in your instantiation, you’ll provide values for all of those variables.

2 Likes

Makes sense Phil. Thanks for the detailed explanation. The example shown in the API documentation confused me a bit here because it as the gid as 12345, which from what i now understand will never work.

Yeah I can see that would add to the confusion.

It’s not that it will never work, just not currently. Imagine a future time when you can create a project template programmatically, and when you do, you can define your own “variables” and what their ids are. Then the id can be anything you choose.

Nonetheless, I’ll point out the issue you had here to Asana as it seems it would be good for the docs to include this additional info about how the id works.

2 Likes

The libraries are not updated. I’ve provided a solution with the dispatcher for the node library: Project Templates missing · Issue #268 · Asana/node-asana · GitHub

2 Likes

@Phil_Seeman I’ve got a Template Project (Legacy) that I use as a template for other Projects with Flowsana. If I change this to the New Project Template, will Flowsana still be able to apply all the subtasks and assignemnts on the New Project Template? Do I have to change anything?

Hi @Nick_Garcia1,

Unfortunately when Asana creates a Project Template 2.0 from a 1.0 template, the 2.0 version is a whole new object in Asana independent of the original project object, so you’ll have to create the workflows in the 2.0 template.

Also note that 2.0 templates don’t yet support Flowsana rule actions in the template’s rule builder, so if you have any rules involving Flowsana that live in the Asana rule builder in your 1.0 template, you’ll have to create those rules in the Flowsana web portal instead (and make sure they can be built there, as the Asana rule builder has a few capabilities the Flowsana web portal does not have.)

@Phil_Seeman If I convert my template to 2.0, can I have Flowsana still make new projects conform to the 2.0 template to use the Auto Due Date Adjustment to operate in the new project?

@Nick_Garcia1 Yes, if I understand the question, the Auto-Adjust Workflow will work the same on projects made from a 2.0 template as they will from a 1.0-template-based project.

@Phil_Seeman it was announced that the is_template will be deprecated in August. Any idea if this is postponed since the force migration did not happen?

I haven’t heard any news on this, sorry.

Hey folks, cross-posting from the weekly API update, we have a new
timeline for New Project Templates that I want to make sure you’re all aware
of.

  • current status (Aug 16): opt-in (Project resources still include the
    is_template field, but your API client can include a
    Asana-Enable: new_project_templates header to receive the new resource
    treatment)
  • next change (Aug 24): opt-out (Project resources will no longer include the
    is_template field by default, but your API client can include a
    Asana-Disable: new_project_templates header to temporarily revert to the old
    treatment)
  • final change (Sep 24): deprecation complete (Project resources will no
    longer include the is_template field, and there will no longer be a way to
    revert to the old treatment)

Please let me know if you have any questions!

Yours in Developer Relations,
Sasha, on behalf of the Asana API Team

1 Like

I know this might be a slightly old topic but we’re just starting with Asana and i’m running into a similar with creating a template via the API. I’m getting the same date issue if I use “1” as the date GID, but if I use “2” it creates it, but it seems that 2 sets the due date, and the start date is not set it seems to just pick a random start date, one project was starting in July one was in August, if I try and put in both “1” and “2” as an array of dates it says that it must contain only one start date or one due date. I only want the due date to populate as well. Only one of my tasks refences the due date, and its being used a 20 days BEFORE the due date. Any way to just have the Due date populate?

Are you having this issue when creating a template, or when creating a project from a template? You’re talking about supplying actual calendar dates so it seems you’re talking about creating a project?

hey folks, a reminder that the Asana-Disable headers will stop working soon (end of September) for New Project Templates. At that point, the API will only return the new schema for New Project Templates and is_template will be no more.

3 Likes

It looks like you can’t query for all templates in an org, do you have to do it team by team? :frowning: Not possible to get templates for an org?

This seems to be in Node, any idea how to do this in Python?

The syntax should be quite close. I had to read the source code to understand how to use it.