Find schema fields that were created on a certain day

Hi,

due to a hiccup our Moxion integration I am left with tons of custom fields in my Shot schema which I now need to remove (those fields were meant to be created in a custom entity but somehow ended up in my Shot schema which may well have been user error in editorial).

Anyway, now I have written a script to compare fields that exist in both the custom entity as well as the Shot entity, but as an extra sanity check I would like to limit that list to only fields that were created on a certain day.
Can somebody help me out with the syntax here?

This is what I got at the moment, how can I now query each field’s creation date:

shot_schema = sg.schema_field_read("Shot")
moxion_schema = sg.schema_field_read("CustomEntity03")
shot_fields = set(shot_schema.keys())
moxion_fields = set(moxion_schema.keys())
exclude_list = ["sg_status_list"]
for common_field in shot_fields.intersection(moxion_fields):
    if common_field.startswith("sg") and (common_field not in exclude_list):
        print(common_field)
        #sg.field_delete("Shot", common_field) # not running this until I'm 100% sure

Thanks in advance,
Frank

bump

Hi @frank!

I think I have a possible solution for you: There is an entity in Shotgun called Field that describes the fields of other entities (kinda meta-filed). If you query that I think you should be able to extract the creation date and filter by it.

Hope that helps!

Cheers,
Fabian

Thanks Fabian, I will try that.

Cheers,
frank

Hey @frank!

Seems you still can’t query DisplayColumns aka Fields directly… but you can indirectly through an EventLogEntry that touched the field you’re interested in:

> sg.find_one(
    'EventLogEntry',
    filters=[
        ('entity.DisplayColumn.entity_type', 'is', 'Shot'),
        ('entity.DisplayColumn.name', 'is', 'sg_status_list'),
    ],
    fields=['entity.DisplayColumn.created_at'],
)

{'entity.DisplayColumn.created_at': datetime.datetime(2008, 11, 11, 19, 52, 48, tzinfo=<shotgun_api3.lib.sgtimezone.LocalTimezone object at 0x10eac8790>),
 'id': 13138,
 'type': 'EventLogEntry'}
1 Like