I’m migrating to a new Shotgun instance, and I want to copy over some entity fields from the old instance. Specifically I have a field on Version
called “Version Code”, with field code sg_ins_version_code_1
and I’d like to create that field in the new instance, with that field code (so my API code continues to work).
When I use the website to create a new field, I don’t seem to get an option to specify the field code, just the user-visible name.
See here for an example.
sg.schema_field_create()
https://developer.shotgunsoftware.com/python-api/reference.html#shotgun_api3.shotgun.Shotgun.schema_field_create
Thanks – that doesn’t look too complicated – I think you’re saying I can use the properties from your gist and pass those into schema_field_create
with the python API shotgun_api3
.
When creating fields in the UI, there’s a process I use to make sure I have the field codes I want.
Create your field by naming it with the field code you want without the sg_
prefix. We know the UI will always prepend with sg_
, so no need to worry about that. In your case, you’d call your field ins_version_code_1
when creating it in the UI.
Once you’ve created the field, edit it right away and change its name for the human-readable version of the name. Because the field code is immutable, Shotgun won’t try to change it. In your case, you could name it Version Code
, and you wouldn’t have to worry about Shotgun automatically generating a field code like sg_version_code
.
Of course, this presupposes that the field code you want isn’t already used otherwise the Shotgun UI will try to generate a unique code which will be different.
So now you have two ways of doing it!