# Querying and/or reviving deleted fields through the python API?

**URL:** <https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104>\
**Category:** Flow Production Tracking\
**Tags:** python-api\
**Created:** [February 3, 2020, 9:41pm UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104 "2020-02-03T21:41:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SIE\_Jake\_Helms](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@SIE\_Jake\_Helms](https://community.shotgridsoftware.com/u/SIE_Jake_Helms)\
**Post date:** [February 3, 2020, 9:41pm UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/1 "2020-02-03T21:41:17Z")

</div>

I’m pretty new to Shotgun. Forgive me if this has been answered.

We have a use case where it’s possible that an entity’s field would get deleted through python script, and then created again. As it stands, this throws an error:

```
# Error: line 1: Fault: file C:\CC\Tools\bxExternal\devs\autodesk\shotgun\python2x\shotgun_api3\shotgun.py line 3464: API schema_field_create() failed, there is a retired field with the same field_name: sg_test_field. Delete the retired field forever from the Trash Page in Shotgun and try again. # 

```

To get around that, I would expect to be able to query whether a field has been ‘retired’ and then ‘revive’ it instead of creating it. I can’t find any documentation on how this would work through the API.

Thanks,  
-Jake

---

<div class="post-metadata">

**Author:** ![jing.liu](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jing.liu/32/888_2.png) [@jing.liu](https://community.shotgridsoftware.com/u/jing.liu)\
**Post date:** [February 4, 2020, 8:31am UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/2 "2020-02-04T08:31:36Z")

</div>

Hi Jake,

It is a very good question. You could read this [find retired](https://developer.shotgunsoftware.com/python-api/reference.html?highlight=retired#shotgun_api3.shotgun.Shotgun.find). And use [this](https://developer.shotgunsoftware.com/python-api/reference.html?highlight=revive#shotgun_api3.shotgun.Shotgun.revive) to revive.

Cheers

Loney

---

<div class="post-metadata">

**Author:** ![SIE\_Jake\_Helms](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@SIE\_Jake\_Helms](https://community.shotgridsoftware.com/u/SIE_Jake_Helms)\
**Post date:** [February 4, 2020, 6:45pm UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/3 "2020-02-04T18:45:57Z")

</div>

Thank you for your response, but I’m still not sure how to query retired _ **fields** _ on an entity. Unless I’m misunderstanding, `Shotgun.find()` and `Shotgun.revive()` only work on entities, not fields.

Can you give me an example script?

---

<div class="post-metadata">

**Author:** ![SIE\_Jake\_Helms](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@SIE\_Jake\_Helms](https://community.shotgridsoftware.com/u/SIE_Jake_Helms)\
**Post date:** [February 5, 2020, 6:45pm UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/6 "2020-02-05T18:45:02Z")

</div>

@jing.liu I was advised by our developer support contact at Autodesk to submit a support ticket for this. If I get a workable solution, I’ll post it here.

---

<div class="post-metadata">

**Author:** ![SIE\_Jake\_Helms](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@SIE\_Jake\_Helms](https://community.shotgridsoftware.com/u/SIE_Jake_Helms)\
**Post date:** [February 6, 2020, 1:39am UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/7 "2020-02-06T01:39:35Z")

</div>

Posting a followup:  
It looks like this is officially unsupported through the API.  
Even to perform this action through the UI, you need admin permissions, so it’s unsurprising that it can’t be scripted.  
The workaround we’ve discussed internally is to periodically generate a list of deprecated fields and have a human (with admin permissions) perform the cleanup.

---

<div class="post-metadata">

**Author:** ![jing.liu](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jing.liu/32/888_2.png) [@jing.liu](https://community.shotgridsoftware.com/u/jing.liu)\
**Post date:** [February 6, 2020, 4:17am UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/8 "2020-02-06T04:17:28Z")

</div>

Hi Jake,

Find doesn’t work field entity. If would be a new feature for schema\_read\_field to get retired field. Very appreciate if you could request [here](https://community.shotgridsoftware.com/t/how-do-i-submit-an-idea-or-feature-request/253)

Thanks

Loney

---

<div class="post-metadata">

**Author:** ![patrickwolf](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrickwolf/32/3931_2.png) [@patrickwolf](https://community.shotgridsoftware.com/u/patrickwolf)\
**Post date:** [December 28, 2024, 11:43am UTC](https://community.shotgridsoftware.com/t/querying-and-or-reviving-deleted-fields-through-the-python-api/7104/9 "2024-12-28T11:43:59Z")

</div>

> [@SIE\_Jake\_Helms](#):
>
> but I’m still not sure how to query retired _ **fields** _ on an entity

I imagine the only way currently is to cache the list of fields and when its queried again to see what the diff between the cached and the current version is
