Skip to content

Instantly share code, notes, and snippets.

@kporangehat
Created November 23, 2021 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kporangehat/19bcd22513a914a1cef37a4c9c285beb to your computer and use it in GitHub Desktop.
Save kporangehat/19bcd22513a914a1cef37a4c9c285beb to your computer and use it in GitHub Desktop.
adding Group from addressings to the context in Create Shipment
# We use the Project context, not the app context, to evaluate the root for all local copies, which shouldn't be
# dependent on individual Versions. This allow as well to have a template defined as a `path` template
# instead of a `string` template and not having TK failing for a missing path on the file system.
project_context = self._app.sgtk.context_from_entity_dictionary(
self._app.context.project
)
field_data = project_context.as_template_fields(
template,
)
# try and get a vendor code if there is a Group in the
# to addressings. This will only take the first Group if
# there are multiple
for user in self._to_users:
if user["type"] == "Group":
to_group_context = self._app.sgtk.context_from_entity(
user["type"], user["id"]
)
field_data.update(
to_group_context.as_template_fields(template)
)
break
root_path = template.apply_fields(field_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment