What is the most efficient way to set a link field automatically when a text field on the same entity is updated?

Hello,

Is it possible to use an expression or a lambda so that when a text field on a given entity is updated, another field, in this case a link one, not a text, is automatically set to a value that depends from the text field it is “attached” to?
Let’s say for example that the Version entity has a sg_link_to_frames link field that needs to be updated when its sg_path_to_frames text field changes to point to the folder containing the frames. What technique would you recommend to this in the most elegant/efficient way?

Thank you!

2 Likes

Hi @mpepe,

Thanks for posting your request in the community.

Not sure if I understand you correctly. Are you trying to get an automatic update of a field with the value of theother field when it’s changed? Unfortunately there is no way to automatically pupulate a field with values from the other field. The only situation I could think of is the query field, whenever the field you are querying on is updated, the query field will get propagated automatically.

Other than the case above, you probably need to script a bit by yourself to get the automation.

Let us know if further help needed.

Cheers,
Ben

1 Like

hello @Ben_xzj,

thanks for following up.
to try and clarify, i was hoping there might be a way to do something like:
field_b = get_processed_value_from(field_a)
rather than using a non explicit external process to “link” both fields together, like a trigger.

but if i understand correctly, this is not possible, other than using a query field, but then field_b would have the exact same value as field_a, which is not what i am after.
thank you for pointing at the documentation, any code example would also be appreciated.
cheers!

Hi @mpepe,

When you say field_b = get_processed_value_from(field_a), what kind of process are you talking about here? Would you like to share more of your user story here and see if any wisdom from the team or in the community you could leverage?

Cheers,
Ben

hi @Ben_xzj,

sure, here is in a nutshell what i’m trying to do:

i’d like to add a custom link field called let’s say “sg_link_to_frames” to the version entity, so that when i click on it, it opens up the file browser into the folder that contains the frames that the “sg_path_to_frames” field of the same entity is set to.

so if i replace field_a and field_b from the example above:
if sg_path_to_frames = '/path/to/frames/frame.#.exr'
then sg_link_to_frames = {'local_path': '/path/to/frames'}
or something along those lines.
but instead of setting the value directly, i’d like to connect the fields so that when sg_path_to_frames is updated, sg_link_to_frames is automatically updated too.
does that make sense?

thanks!

Hi @mpepe,

There’s no scripting capability inside Shotgun that would currently allow this. You would have to implement this outside Shotgun using our APIs. Shotgun’s Event Daemon framework and our Webhooks (as of this writing in closed Beta) are two systems that help streamline deployment of such automations.

The docs of the Shotgun Event Daemon project should help you get started.

2 Likes