Jump to content

dynamic enumerator and current selection


Tim Edelmann

Recommended Posts

Hey everybody, 

 

while setting up a dynamic-enumerator-action, we noticed, that the information on the currently selected element doesn't help to retrieve an actual object. We always get 'None' as a result. 

 

This is the event, that comes in:

{
  "topic": "ftrack.dynamic-enumerator",
  "source": {
    "id": "c73c09beff154613ba61300782bb836e",
    "user": {
      "username": "TEdelmann",
      "id": "75b59aae-e1bb-11e7-ad88-7ab7a47c9dda"
    }
  },
  "target": "",
  "data": {
    "attributeName": "Briefing_Workflows_00_Maya_Config",
    "sorters": [],
    "filters": [
      {
        "disabled": "True",
        "property": "name",
        "root": "data",
        "initialConfig": {
          "disabled": "True",
          "property": "name",
          "root": "data",
          "id": "ft-dynamicenumerator-2000671-query-filter"
        },
        "id": "ft-dynamicenumerator-2000671-query-filter"
      }
    ],
    "query": "",
    "groupers": [],
    "recordData": {
      "changes": {},
      "entity": {
        "entityId": "883b74ea-132b-11e8-ae79-7ab7a47c9dda_15",
        "entityType": "task"
      }
    }
  },
  "in_reply_to_event": "None",
  "id": "27304c3ea333491fa793b457e91f7966",
  "sent": "None"
}

As you can see, there is given an  entity in 'recordData'. But for some reason, we can't query or get the actual object from it. This is what we tried so far..

 

obj_type = event['data']['recordData']['entity']['entityType']
obj_id = event['data']['recordData']['entity']['entityId']
# obj_id = event['source']['id']
# selected_object = self.session.get('TypedContext', obj_id)
# selected_object = self.session.query('Task where id is "{0}"'.format(obj_id)).first()
selected_object = self.session.query('{0} where id is "{1}"'.format(obj_type, obj_id)).first()

 

selected_object is always None. 

 

any suggestions? How are we supposed to get the current selection, when reacting on 'topic=ftrack.dynamic-enumerator'?

 

 

Alternatively, it would be very helpful, if the information on what is currently selected, coulde be retrieved in a general way (i.e. like session.getCurrentSelection())

 

thanks a lot in advance

 

 

 

Tim

Link to comment
Share on other sites

Additional information: 

 

We noticed, that the ids look different and we don't know why??

normal ids look like this: '75b59aae-e1bb-11e7-ad88-7ab7a47c9dda'

while the one retrieved here looks something like this: '75b59aae-e1bb-11e7-ad88-7ab7a47c9dda_48'

this '_48' breaks it!

 

PLUS:

 

The 'entityType' given in 'event['data']['recordData']['entity']['entityType']' is not starting with a Capital letter, which breaks it too!

 

 

So if we remove the '_48' and use 'TypedContext' instead of the given type, we're able to query the object. 

 

 

Could anybody give us some more insight here?

 

Thanks again

Link to comment
Share on other sites

Hi Tim,

Sorry for the confusion on this - you're correct, the id is wrong when accessed from the sidebar. To work around this you can do the following:

if '_' in entityId
	realId, junk = entityId.split('_')

As for the entityType - this is old style entity type from the backend. Instead of using 'task' you would want to use 'TypedContext' on the session:

session.get('TypedContext', realId)

 

Link to comment
Share on other sites

  • 3 years later...
On 4/19/2018 at 3:29 PM, Mattias Lagergren said:

Hi Tim,

Sorry for the confusion on this - you're correct, the id is wrong when accessed from the sidebar. To work around this you can do the following:





if '_' in entityId
	realId, junk = entityId.split('_')

As for the entityType - this is old style entity type from the backend. Instead of using 'task' you would want to use 'TypedContext' on the session:





session.get('TypedContext', realId)

 

Hi Mattias,

Sorry to bring up this old post, but this is really related to my question:

I don't know how can I get info like "project" from the dynamic-enumerator event who is triggered by a custom attribute of dynamic-enum type on the filter section ?

 

I notice that the "recordData" in the event was empty, but there is one data named "filters", so I guess it is used to record the info
about the current filters, but it doesn't look like it has the data I want.

 

{
    u'attributeName': u'episode', 
    u'sorters': [], 
    u'filters': [
        {
            u'disabled': True, 
            u'property': u'name', 
            u'root': u'data', 
            u'initialConfig': {
                u'disabled': True, 
                u'property': u'name', 
                u'root': u'data', 
                u'id': u'ft-dynamicenumerator-2000574-query-filter'
            }, 
            u'id': u'ft-dynamicenumerator-2000574-query-filter'
        }
    ], 
    u'query': u'', 
    u'groupers': [], 
    u'recordData': {}
}

 

So, in this situation, is there any chances I can get the info about like "project" ?
Thanks a lot.

 

 

Liam

Link to comment
Share on other sites

  • 1 year later...

Hi @Liam,

Which object was your dynamic enumerator custom attribute added to? If you add a dynamic enumerator to a `Project` you should get the following data in `event['data']`:

{
  'groupers': [],
  'attributeName': 'dynamic_enum_01',
  'recordData': {
    'changes': {},
    'entity': {
      'entityId': '02a4f54a-f17a-11ec-b799-e2c3e97de4aa_9',
      'entityType': 'show'}
    },
    'filters': [
      {
        'disabled': True,
        'property': 'name',
        'initialConfig': {
          'disabled': True,
          'property': 'name',
          'root': 'data',
          'id': 'ft-dynamicenumerator-2000512-query-filter'
        },
        'root': 'data',
        'id': 'ft-dynamicenumerator-2000512-query-filter'
      }
    ],
  'sorters': []
}

Notice that the `entityType` value is `show`. You can use the `split()` trick shared by @Mattias Lagergren to get your `id` and then do a `session.get('Project', <id>)`.

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...