Designing URL Pages and Web Page Widgets

The URL will dynamically update for any shot a user is viewing.

There are three fields that pertain to the current user logged into Shotgun that can also be used in the URL string:

  • {current_user.login}
  • {current_user.id}
  • {current_user.fullname}

To find the field codes, go to the "fields" page under the Settings menu and look at the "Field Code" column.

Pro Tip:  Try adding a text field to the entity with the URL you want to load on each entity page. For example, you can create a field called "Wiki" on the Asset entity that you fill in the URL for every asset. Then on your page, you can insert that field code into the URL field in brackets: {sg_wiki}. That will simply insert the URL from the text field and load in the page.

Using custom URLs to load full page forms for creating new entities

You can bookmark or create a URL that opens up a form to create a new Entity (Asset, Shot, Task, etc.). This is handy if you want to bookmark a "New Note" page for quick access.

Developers can also add links to their tools and applications that deep link people into a form that is pre-populated with the correct data. For example, you can build a tool that allows a supervisor who is reviewing Versions to go to a pre-filled Note form. The Note form can have a link to the Version the supervisor was looking at and be addressed to the Artist who created that Version. Or you can embed the new Note form right into your QT application.

How the URL works

The base site URL is appended with "new/" and then the Entity name. The URL for a new Note would look like this:

https://example.shotgunstudio.com/new/Note

The resulting page looks like this:

Use system entity names in URLs

Consult the entities section of the site preferences page for a complete list of these names. Note that these are not the same as the display names. For example, a Person would actually be HumanUser. Below are a few more examples:

New Asset form

https://{your shotgun base url}/new/Asset

New User form

https://{your shotgun base url}/new/HumanUser

New Invoice form (Custom Entity 1)

https://{your shotgun base url}/new/CustomEntity01

Pass values to the form

You can pass more information to the form through the URL. Here are some examples:

Specify a project

You can pass in a project name into the URL to auto-populate the project dropdown. If there are duplicate project names, the dropdown will ignore this query string parameter.

?project=Demo

Specify other default field values

Use system field names to populate other form fields, using the same {"name": value} notation used for the API. For example:

?defaults={"content":"testing","sg_status_list":"ip"}

Project names with spaces

Any Project names that have spaces in them (i.e., "Demo Project X") should have the spaces’ URL encoded and replaced with %20. For example:

https://{your shotgun base url}/new/Asset?project=Demo%20Project%20X&defaults={"content":"testing","sg_status_list":"ip"}

New Note form URL with defaults

You can pass in text into the URL to populate the actual Note. For example:

https://example.shotgunstudio.com/new/Note?project=Demo Project&defaults={"content": "This is a test note subject with a\nline break.","sg_status_list":"ip"}

Multi-Entity field values

For multi-entity fields that accept multiple values like Ticket.addressings_cc, the syntax would look like this:

https://example.shotgunstudio.com/new/Ticket?project=Demo%20Project&defaults={"addressings_cc":[{"type":"HumanUser","name":"John%20Magoo"}]}
Pro tip: You can also create a page or widget with a filter saved that has all those values in it. For example, if you have a Shot widget, and the filter is “Sequence is Seq_001”, whenever you create a Shot from that widget, the “Sequence” field would already be populated with “Seq_001.”

For more info, see Designing canvas pages.

Follow

0 Comments

Please sign in to leave a comment.