Jump to content

Creating new task types through api


Fernando

Recommended Posts

Hello,

I am trying to figure out how I can create new task types through the api. It seems from this example that I should use:

session.create('TaskTypeSchemaType', {
        'task_type_schema_id': task_schema['id'],
        'type_id': typ['id']
    }

but in the example the types already exist, how would I create my own type with id? Also shouldn't I give in a name for the type? 
Just to clarify I would like to create a new task type through the api just like the Create button allows you to do in the System Settings>Types section.

image.png.1d69976cc1dbbe3629b6b27e1d9be920.png

Link to comment
Share on other sites

Hi Fernando,

To create the actual Type object (which is what you're looking at in this list) you can start with this:

t = session.create('Type', {'name':'foo'})
session.commit()

This will create a type that will not be linked to any workflow schema. To view the attributes you can specify, you can use our in app API Reference that you can find under Help in the user menu (your user icon in the top right of the UI).

Next, to tie this new Type object to a schema you can do as follows (I'm using the VFX schema as an example):

project_schema = session.query("Project where name = 'VFX'").first()
task_type_schema = project_schema["task_type_schema"]
task_type_schema["types"].append(t)
session.commit()

So the API model is as follows:

  • A ProjectSchema has a TaskTypeSchema
  • A TaskTypeSchema has one or many Types
  • The Type is what shows up in the Workflow -> Types page of the System Settings.

I hope this helps!

Cheers,
Patrick

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...