# Tk-multi-workfiles - 'saveas\_default\_name' setting

**URL:** <https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729>\
**Category:** Pipeline Integrations\
**Created:** [November 11, 2019, 2:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729 "2019-11-11T14:56:42Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debatty\_Francois](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/debatty_francois/32/1167_2.png) [@Debatty\_Francois](https://community.shotgridsoftware.com/u/Debatty_Francois)\
**Post date:** [November 11, 2019, 2:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/1 "2019-11-11T14:56:42Z")

</div>

Hi there,

Sorry if this sounds as a stupid question but i’m trying to use the ‘ **saveas\_default\_name** ’ setting inside of ‘ **tk-multi-workfiles2.yml** ’ so that Maya automatically fills the ‘name’ field with the asset name when trying to save for the first time.  
When i add that setting, the Maya reference box shows that the setting is no longer by default and displays the string i used.  
But the problem is that the ‘name’ field is always automatically populated with the string ‘scene’.  
What am I doing wrong here? What do I need to do to get the asset name by default when trying to save?

Thanks a lot in advance!  
Francois

---

<div class="post-metadata">

**Author:** ![johnny.duguid](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/johnny.duguid/32/4_2.png) [@johnny.duguid](https://community.shotgridsoftware.com/u/johnny.duguid)\
**Post date:** [November 11, 2019, 11:33pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/2 "2019-11-11T23:33:39Z")

</div>

Hey @Debatty_Francois! A quick heads up I’ve moved this to the #pipeline category to get the right 👀 on it.

---

<div class="post-metadata">

**Author:** ![tannaz](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tannaz/32/32_2.png) [@tannaz](https://community.shotgridsoftware.com/u/tannaz)\
**Post date:** [November 12, 2019, 2:40am UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/3 "2019-11-12T02:40:51Z")

</div>

Hi François –

I just tested this, and it worked for me. If I set a value for `saveas_default_name`, that’s what I get in the name field when I do a Shotgun-\> File Save in Maya. There are a couple things to point out here:

- I suspect that you set this value in the wrong environment – when you’re saving a file, for example, to a task an a pipeline step on an Asset, you’re in the `asset_step` environment. So, you’ll want to make sure you’re updating the correct settings – those that `config/env/asset_step.yml` includes.

In the Default Config, this would be the `settings.tk-multi-workfiles2.asset_step` block of `config/env/includes/settings/tk-multi-workfiles2.yml` (as seen below), but if your pipeline configuration is set up differently, this may vary.

> <https://github.com/shotgunsoftware/tk-config-default2/blob/master/env/includes/settings/tk-multi-workfiles2.yml#L213-L238>

- Having said that, I don’t believe you can set `saveas_default_name` to a dynamic value – you can only use it with a static string.
- What you might want to do is modify your templates in `config/core/templates.yml` so that _instead of_ `{name}`, you’re using `{Asset}`. Note that if you don’t have a `{name}` field in your template, the text field in the File Save dialog will go away, and the file path will be fully automatically generated, with no input from the user.

Some relevant docs:

- [This section of the Editing a Config guide](https://developer.shotgunsoftware.com/37f575b8/?title=Editing+a+Config#find-where-to-set-the-value-for-allow_task_creation) talks about how to know where to make the modifications when you edit an app setting.
- [The Environment Configuration Reference](https://developer.shotgunsoftware.com/487a9f2c/?title=Environment+Configuration+Reference) talks about how includes work in Toolkit configurations
- [This guide](https://developer.shotgunsoftware.com/56b441c6/?title=Filesystem+configuration) talks through modifying your schema and templates

---

<div class="post-metadata">

**Author:** ![Debatty\_Francois](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/debatty_francois/32/1167_2.png) [@Debatty\_Francois](https://community.shotgridsoftware.com/u/Debatty_Francois)\
**Post date:** [November 12, 2019, 2:50pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/5 "2019-11-12T14:50:04Z")

</div>

Hi Tannaz,

Thank you so much for the quick answer!

You’re right, I was setting the value in the wrong environment.  
And modifying `config/core/templates.yml` gives me exactly what i was looking for!

Thank you again for your help and for the useful links.

Francois

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [November 12, 2019, 2:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/6 "2019-11-12T14:56:35Z")

</div>

I just thought I’d share this link, as Barbara provided a suggestion that allowed her to dynamically set the default save name:  
[https://groups.google.com/a/shotgunsoftware.com/forum/#!searchin/shotgun-dev/workfiles$20name|sort:date/shotgun-dev/RcbThuYFQuk/OmqQVZNJBAAJ](https://groups.google.com/a/shotgunsoftware.com/forum/#!searchin/shotgun-dev/workfiles%2420name%7Csort:date/shotgun-dev/RcbThuYFQuk/OmqQVZNJBAAJ)

---

<div class="post-metadata">

**Author:** ![Debatty\_Francois](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/debatty_francois/32/1167_2.png) [@Debatty\_Francois](https://community.shotgridsoftware.com/u/Debatty_Francois)\
**Post date:** [November 12, 2019, 4:12pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/7 "2019-11-12T16:12:27Z")

</div>

Hi Philip,

This solution looks pretty neat! I’ll give it a try 😉

Thanks,  
Francois

---

<div class="post-metadata">

**Author:** ![Diego\_Garcia\_Huerta](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/diego_garcia_huerta/32/373_2.png) [@Diego\_Garcia\_Huerta](https://community.shotgridsoftware.com/u/Diego_Garcia_Huerta)\
**Post date:** [August 6, 2020, 11:45am UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/8 "2020-08-06T11:45:40Z")

</div>

I know this is fairly old, but this solution works like a charm, thanks so much @blaigneau!  
I had no clue you could trick string config values to be resolved with a core hook. I wonder if anyone has found a way for the hooks to not be core hooks, ie .being able to specify `{engine}` `{config}`, etc…

---

<div class="post-metadata">

**Author:** ![zavinator](https://avatars.discourse-cdn.com/v4/letter/z/57b2e6/32.png) [@zavinator](https://community.shotgridsoftware.com/u/zavinator)\
**Post date:** [June 5, 2023, 3:23pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/9 "2023-06-05T15:23:05Z")

</div>

I wonder how this can be used to set name based on the pipeline step.  
Because the bundle\_obj.context has step/task/entity None when saving a new scene - there is only valid context.project.  
The step/task/entity are still None regardless the selection in save dialog.

---

<div class="post-metadata">

**Author:** ![mychoko](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mychoko](https://community.shotgridsoftware.com/u/mychoko)\
**Post date:** [June 7, 2024, 11:44pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/10 "2024-06-07T23:44:04Z")

</div>

hello and thanks for the suggestion! very late in the game here and the link you provided does not seem to work anymore. any chance this is available elsewhere? 🙏

---

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [June 11, 2024, 5:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/11 "2024-06-11T17:56:04Z")

</div>

Here it is.  
Add this to your core/hooks folder as `custom_name_resolver_from_ctx.py`

Then in workfiles2 you can add this to the `saveas_default_name` setting:

`saveas_default_name: hook:custom_name_resolver_from_ctx:task_name`

```python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Mac Guff
# ----------------------------------------------------
#
# @author: Barbara Laigneau <barbara@dark-shot.com>
# @brief: Core Hook to get a name from a context

from sgtk import Hook
import os

class ProceduralNameFromContext(Hook):
    """
    """

    def execute(self, setting, bundle_obj, extra_params, **kwargs):
        """
        Get a name from the current context

        :param setting: The name of the setting for which we are evaluating
                        In our example above, it would be template_snapshot.

        :param bundle_obj: The app, engine or framework object that the setting
                           is associated with.

        :param extra_params: List of options passed from the setting. If the settings
                             string is "hook:hook_name:foo:bar", extra_params would
                             be ['foo', 'bar']

        returns: needs to return the name of the file, as a string
        """

        resolve_mode = extra_params[0]
        # the mode is basically the parameter passed from the config value - in this case task_name

        if resolve_mode == "task_name":
            ctx_task = bundle_obj.context.task
            return ctx_task["name"] if ctx_task else "scene"
        elif resolve_mode == "entity_name":
            ctx_entity = bundle_obj.context.entity
            return ctx_entity["name"] if ctx_entity else "scene"
        else:
            return "scene"

```

---

<div class="post-metadata">

**Author:** ![mychoko](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mychoko](https://community.shotgridsoftware.com/u/mychoko)\
**Post date:** [June 11, 2024, 6:47pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/12 "2024-06-11T18:47:27Z")

</div>

brilliant, thanks a bunch!

---

<div class="post-metadata">

**Author:** ![guilhermecasagrandi](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/guilhermecasagrandi/32/6656_2.png) [@guilhermecasagrandi](https://community.shotgridsoftware.com/u/guilhermecasagrandi)\
**Post date:** [May 28, 2025, 11:54pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/13 "2025-05-28T23:54:15Z")

</div>

That’s very good, but WF2 can’t retrieve the task from selection, right? The context remains the same as the current open file.  
It’d be awesome to retrieve the task from user selection and then set the file name parameter based on that information.

---

<div class="post-metadata">

**Author:** ![guilhermecasagrandi](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/guilhermecasagrandi/32/6656_2.png) [@guilhermecasagrandi](https://community.shotgridsoftware.com/u/guilhermecasagrandi)\
**Post date:** [May 29, 2025, 12:04am UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/14 "2025-05-29T00:04:05Z")

</div>

Ideally, it’d be possible to retrieve the name from the selected tasks, as shown in the image.

 ![Captura de tela 2025-05-28 210128](https://global.discourse-cdn.com/shotgunsoftware/original/2X/8/8d093d55c16c3c94c12a043af9c1cf9f5d1dacab.png)

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [May 29, 2025, 6:37pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/15 "2025-05-29T18:37:08Z")

</div>

omg, I totally forgot you could create arbitrary hooks for settings values… ! That is awesome!

---

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [May 29, 2025, 6:40pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/16 "2025-05-29T18:40:01Z")

</div>

I think for that the tk-workfiles2 app would need to send out some sort of signal when you select the task, maybe it can set a runtime only app setting or simply an environment variable (`TK_MULTI_WORKFILES2_CURRENT_SELECTED_TASK_ID`).

---

<div class="post-metadata">

**Author:** ![guilhermecasagrandi](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/guilhermecasagrandi/32/6656_2.png) [@guilhermecasagrandi](https://community.shotgridsoftware.com/u/guilhermecasagrandi)\
**Post date:** [May 30, 2025, 11:59am UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/17 "2025-05-30T11:59:03Z")

</div>

Is that possible right now?

---

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [May 30, 2025, 2:12pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/18 "2025-05-30T14:12:49Z")

</div>

You’d have to fork the app and make that change but I’m just suggesting its a way to do it 🙂

Altough there are probbaly more things that need to happen because the `default_saveas_name ` function would need to be triggered every time you select a task.  
It may make the app laggy.
