The specification of the "properties" argument of sg.schema_create_field()

Hi,

I have a question about the specification of the “properties” argument of sg.schema_create_field() in SHOTGRID API.

I think the “properties” is a dictionary with different keys and values depending on the data_type of the field, but I can’t find that information in the API Reference, at least not in the method description.
https://developer.shotgridsoftware.com/python-api/reference.html#shotgun_api3.shotgun.Shotgun.schema_field_create

So I would like to know where to find an information or sample code of the specification of the “properties” argument for each field’s data_type.

For example,
if the data_type is “list”, then

  • properties[“default_value”] [“value”].
  • properties[“valid_values”] [“value”].

If the data_type is “description”, then

  • properties[“summary_default”][“value”]
  • properties[“description”][“value”]

I think this argument should be optional, but it currently stops with the following exception error if I omitted the argument (why not make it optional? The default settings for each field can be easily set in the CSV import of the WebUI, all I want to do with the API is to automatically generate a number of custom fields.)

Shotgun_api3.shotgun.Fault: API schema_field_create() missing required 'properties' ["valid_types"].

Best,

I made a typo in the above section and will correct it as follows.

> If the data_type is “text”, then

Hi,

I soved this myself that I should get the properties information for each field by myself from the dictionary information obtained by sg.schema_field_read(), and pass it to the properties argument of schema_field_create().

Thanks,

1 Like

Thanks for following up with the solution you found. It will no doubt save someone the same headache in future :+1:

This kind of validation against the schema is a common pattern, especially when updating fields with list data types where the values could change outside of code.

1 Like