Jump to content

Manage Custom Attributes


Remus Avram

Recommended Posts

I am trying to create a custom attribute but I am getting an error regarding permissions value:

cmd:

session.create('CustomAttributeConfiguration',
                                             {
                                              "key": name,
                                              "label": label,
                                              "attribute_type": attribute_type,
                                              "default": default_value,
                                              "entity_type": entity_type,
                                              "is_hierarchical": is_hierarchical,
                                              },
                                              )

Error:

# (MainThread)|Server reported error: OperationalError((OperationalError) (1048, "Column 'permissionid' cannot be null") 'INSERT INTO variable_register (id, `key`, entity_type, object_type_id, core, label, sort, type_id, permissionid, write_permissionid, is_hierarchical, config, project_id, `default`, groupid)  VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'  (u'17885cf8-89fa-4e03-89b2-a696906ec7ea', 'test_custom attribute', 'task', None, 0, 'test_custom_att', 0,  None, None, None, 0, None, None, '1', None))

Unfortunately, there is no 'permissionid' in the custom attribute keys.

Current keys: 

"""
sort
core
key
entity_type
default
type
type_id
label
is_hierarchical
values
object_type_id
project_id
config
id
"""

Could you please post an example of creating a new custom attribute using the API?

Link to comment
Share on other sites

  • 2 weeks later...

What about querying for the contents of specific custom attributes? You cite the below example to return a list of all of the attributes.

>>> session.query('CustomAttributeConfiguration').all()

Does non-hierarchical in this situation mean that you can't go any deeper than the list of custom attributes?

 

Link to comment
Share on other sites

Quote

What about querying for the contents of specific custom attributes? You cite the below example to return a list of all of the attributes.


>>> session.query('CustomAttributeConfiguration').all()

The code above is just about listing all available custom attributes in ftrack. The actual custom attribute values are easiest to access from the entities themselves. See this article: http://ftrack-python-api.rtd.ftrack.com/en/stable/example/custom_attribute.html

A "hierarchical" custom attribute is a custom attribute that can exist on multiple levels in the hierarchy, see http://ftrack.rtd.ftrack.com/en/stable/administering/using_custom_attributes.html#hierarchical-attributes

Link to comment
Share on other sites

I realize that my post was not entirely clear--that's not what I want to query. I want to know what options are available to use for a particular custom field when creating a project.

So let's say we have a custom field called "location" for projects, which is an enumerator type. I want to be able to create projects and set their locations in the process. In order to do this, I need to query what values exist in the location enumerator. I shouldn't be able to set a location for the project that doesn't exist.

I also posted this question as a separate post here:

 

Link to comment
Share on other sites

Hi,

I have responded via email but will write here in case someone else would like to know.

You can query a configuration of a custom attribute and get the config for it:

configuration = session.query(
    'select config from CustomAttributeConfiguration where key is "YOUR-ATTRIBUTE-KEY"'
).one()

print json.dumps(configuration['config'])

 

Link to comment
Share on other sites

  • 2 months later...

Hi everyone!

On 25.7.2016 at 9:28 AM, Björn Rydahl said:

it is currently not possible to create custom attributes via the API.

You would need to create it via settings in the UI, and then use it from the API.

Is it somehow possible to add custom attributes to timelogs (via API or UI)?

Thanks.

 

Laura

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...