Jakub Trllo Posted July 6, 2019 Report Share Posted July 6, 2019 Hi, I hope this issue is not caused because we don't have newest ftrack_api version and please let me know if we're handling with old issue. Hierarchical custom attributes makes us unhappy at the moment. Api do not return `None` if default value is set which breaks everything with hierachical attributes for us. Example: Hierarchical Custom attribute `hier_attr` with default value `100` in hierarchy: - project_xy - `hier_attr` is set to `50` / API will return `50` -- hier_1 - `hier_attr` is set to `200` / API will return `200` --- hier_1_1 - `hier_attr` is not set / API will return `100` If value is not set, `None` should be returned (which is acceptable possibility), or `200` in this case and only if all parents don't have set that custom attribute's value then default should be returned like values in web app. Second variant is better for us, but first one also make sence and meets the documentation. Is that possible? Thanks, Jakub Trllo Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted July 9, 2019 Report Share Posted July 9, 2019 HI @Jakub Trllo, >> I hope this issue is not caused because we don't have newest ftrack_api version I've been checking this with the one of latest api (1.8.0), but I would expect the same behaviour from previous versions too. If you suspect is an api version issue please let me know what version are you using so I can try to replicate. >> Api do not return `None` if default value is set Setting the default value on the custom attribute indeed override the None if the value is not set, that's what is for. >> If value is not set, `None` should be returned If you want it to return None, you simply have to leave the default value empty, tested now and seems to be working as expected. >> [....] if all parents don't have set that custom attribute's value then default should be returned like values in web app. On checking the previous hierarchy item, that's something I'd leave to the coder to implement as custom logic , rather than providing it by default (as it might cause confusion) Hope it helps! L. Link to comment Share on other sites More sharing options...
Jakub Trllo Posted July 9, 2019 Author Report Share Posted July 9, 2019 Hi, >> If you want it to return None, you simply have to leave the default value empty, tested now and seems to be working as expected. That's what we are recommending now but our clients mess it up sometimes. >> Setting the default value on the custom attribute indeed override the None if the value is not set, that's what is for. I expect the same `only` if it is not hierarchical attribute - hierarchical attributes should have different properties in API because they have different properties in web app and I don't want to get default value if any of parents value is set. Or better I want to get default value of hierarchical attribute only on project entity if do not have set it because that's top entity. On lower entities doesn't make sence return default value because may return nonsence data (like in example upwards). Exist a way how to get information about custom attribute is set or not on entity? Special query or something? That's all I need at the moment... Thanks, Jakub Link to comment Share on other sites More sharing options...
Jakub Trllo Posted October 30, 2019 Author Report Share Posted October 30, 2019 Hi, have this issue any progress? Any suggestions how hierarchical custom attributes may return expected values or "real" values (not default) through ftrack API? Thanks, Jakub Trllo Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted October 31, 2019 Report Share Posted October 31, 2019 Hi @Jakub Trllo, hierarchical attributes are tricky. Hope this snippet can help you out. If case does not let us know! Cheers. L. Link to comment Share on other sites More sharing options...
Jakub Trllo Posted October 31, 2019 Author Report Share Posted October 31, 2019 Hi, Thanks! That is very helpful snippet. I have addition question: We need to get all hierarchical values for each entity in project, with this snippet it will probably take ages... Is possible to modify query to be able get values for multiple entities and custom attributes at once. Or when we'll add more query actions to `data` argument to `session.call` method they'll be processed without request to ftrack server for each entity and custom attribute? EDITED: I've modified the query to get all at once and it actually works and returns only data of really set entities. So now I only have to go through parents and find values of attributes that are not set, so I'm happy now. Thanks again Jakub Link to comment Share on other sites More sharing options...
Jakub Trllo Posted November 20, 2019 Author Report Share Posted November 20, 2019 I'll just add one more info for those who may want do something similar. It is better to not use "CustomAttributeValue" table but "ContextCustomAttributeValue" in the query because CustomAttributeValue does not contain all data for all custom attributes. (Not sure why maybe someone from Ftrack may answer?) session.call([{ 'action': 'query', 'expression': ( 'select value, entity_id from ContextCustomAttributeValue' 'where entity_id in ({0}) and configuration.key is "{1}"' .format( ', '.join( ['"{0}"'.format(entity_id) for entity_id in entity_ids] ), attribute_name ) ) }]) Link to comment Share on other sites More sharing options...
Jakub Trllo Posted November 21, 2019 Author Report Share Posted November 21, 2019 (edited) Maybe Bug Report: Now I've found out that those custom attributes which were not found in "CustomAttributeValue" can't be set with API. When I try to set them in session, PermissionError is raised on commit, but Web app shows me that I have permissions. Exception: ftrack_api.exception.ServerError: Server reported error: PermissionError(Permission denied: not allowed to 'create' 'Variable_Value'. Missing the required 'Pixel aspect write' permission.) EDITED: This started to happen yesterday and yesterday was our Ftrack updated to version 4.3, does it mean it has changed something on server side for custom attributes we should know, it is a bug or It's just our mistake? Edited November 21, 2019 by Jakub Trllo new findings Link to comment Share on other sites More sharing options...
JPrydz Posted November 26, 2019 Report Share Posted November 26, 2019 Hi Jakub, Thanks for the information on this. Fixed in 4.3.3. Regards, Johan Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now