Custom fields specific to a project, not workspace

I’m trying to create projects via the API and each project has to have some custom fields.

From what I read in the docs, the way to do this is to

  1. create custom fields in the workspace and then
  2. assign the custom fields using custom_fields_settings to the project.

Is there a way to create custom fields which are not in the workspace, but rather exist only for a single project?

The reason behind me wanting to do this is that custom fields with the same name will be used in more than one project, but their enum values need to be different.

I believe there is a way to do this, perhaps undocumented, because if I create a project using CSV import in the GUI, the custom fields are not visible in the workspace, but are present in the project when accessed via the API.

Hi @Goran_Radola and welcome to the forum,

I think you’re right that there’s not a way to create a local project-specific custom field via the API.

I haven’t used it but there is an is_global_to_workspace property on a custom field; you might want to play around with setting that and see if that helps you.

Hi! Thanks for the reply!

It gave me something to search the forum with and I’ve found the solution in these two topics:

The gist is, you need to send a POST to addCustomFieldSetting just like in the docs, but instead of setting custom_field to an existing GID, you pass a JSON definition of a custom field.

In my case, when using the Node API, it looks something like this:

client.projects.addCustomFieldSettingForProject(
  project.gid, { 
    custom_field: { 
      name: 'Test Custom Field', 
      type: 'enum', 
      enum_options: [{ name: 'first' }, { name: 'second' }], 
      "resource_subtype": "enum"
    },
  is_important: true 
});

Afterwards, the added custom field is visible in the project’s custom_field_settings.

1 Like

Ah, excellent, thanks, @Goran_Radola!

Hi, is this solution still working? I’m trying to do the same, but it same that there is no “addCustomFieldSettingForProject” on client.projects.

This is my code:

  const client = asana.Client.create().useAccessToken(params.accessToken);

  const { data } = await client.projects.addCustomFieldSettingForProject(params.project, {
    custom_field: {
      name: 'test',
      type: 'text',
    },
    is_important: true
  });

But I receive this error: TS2339: Property ‘addCustomFieldSettingForProject’ does not exist on type ‘Projects’.

Hi @Fabio_Fioramonti,

Which client library are you using?

Hi @Phil_Seeman , thank you for your reply, I’m using version 1.0.2 of the nodejs module took from npm

Hmm, sure seems like it should be in there, from looking at the Node client source code.

@Bastien_Siebman I think you use the Node library? Any ideas?

I think it’s an issue with typescript and types because using @ts-ignore it works!

1 Like