# Standalone publisher matching settings to current item

**URL:** <https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891>\
**Category:** Pipeline Integrations\
**Tags:** publish\
**Created:** [August 30, 2022, 9:38am UTC](https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891 "2022-08-30T09:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [August 30, 2022, 9:38am UTC](https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891/1 "2022-08-30T09:38:16Z")

</div>

hi, the same question was asked before here [Publish2 UI settings transfer from one item to another](https://community.shotgridsoftware.com/t/publish2-ui-settings-transfer-from-one-item-to-another/13847) though not fully developed. Basically, when publishing multiple items of the same type, they end up with identical settings, even though in the ui different ones have been entered.

Now I realize, the settings passed to `set_ui_settings` are a list, where each item is the corresponding publish item of the same type. So when setting the ui settings, how do you figure out the index of the current item inside settings?

For instance, here I just take the first item

```auto
    def set_ui_settings(self, widget, settings):
        settings = next(iter(settings))

        if "export_options" in settings and settings["export_options"] is not None:
            self.export_options.setText(str(settings["export_options"]))

```

How do I obtain the correct index from settings?

---

<div class="post-metadata">

**Author:** ![tweekazoid](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tweekazoid/32/4534_2.png) [@tweekazoid](https://community.shotgridsoftware.com/u/tweekazoid)\
**Post date:** [August 30, 2022, 12:21pm UTC](https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891/2 "2022-08-30T12:21:49Z")

</div>

> [@mmoshev](#):
>
> `set_ui_settings`

I had to in the end result to basicaly making sure shotgrid thinks the new selection is always different item. (as shown in video )

tk-multi-publish2\v2.6.3\python\tk\_multi\_publish2\dialog.py  
ln: 434

```auto
        # Now figure out if we need to create/replace the widgets.
        if (
            # If we had a selection before
            self._current_tasks
            and
            # and it was of the same type as the new one.
            # self._current_tasks.is_same_task_type(new_task_selection)
            self._current_tasks == new_task_selection
        ):

```

and on publish item class, i had to make sure to not use options if list has multiple entries:

```auto
def set_ui_settings(self, widget, settings):
        if len(settings) > 1:
            raise NotImplementedError()
        f_sett = settings[0]
        widget.settings = f_sett.get( "export_options", {} )

```

---

<div class="post-metadata">

**Author:** ![tweekazoid](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tweekazoid/32/4534_2.png) [@tweekazoid](https://community.shotgridsoftware.com/u/tweekazoid)\
**Post date:** [August 30, 2022, 12:59pm UTC](https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891/3 "2022-08-30T12:59:45Z")

</div>

OK to your question.  
In order to get correct index from settings, you first have to store some unique identifier in each setting , like

```auto
settings['export_settings']['uuid'] = uuid.uuid4()

```

```auto
def set_ui_settings(self, widget, settings):
    for s in settings:
        if 'export_settings' not in s :
            continue
        s_uuid = s['export_settings'].get('uuid', None)
        c_uuid = self.get_ui_settings( widget ).get('export_settings', {}).get('uuid', None)
        if s_uuid and s_uuid == c_uuid:
            widget.settings = s
            return
        elif s_uuid and c_uuid is None :
            # the first time item is accesed
            widget.settings = s 
            return

```

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [August 31, 2022, 9:42am UTC](https://community.shotgridsoftware.com/t/standalone-publisher-matching-settings-to-current-item/15891/4 "2022-08-31T09:42:10Z")

</div>

Haha that’s… evil. /s

I wonder if direct equality comparison would work. It’s basically calling `get_ui_settings`, and finding the settings in the list that match.  
On the other hand, it sounds like something that should be solved inside `tk-multi-publish2`. I get the idea that you might want to consider what other items’ settings are, but in the base case I just wany “my” settings.

Thanks for the insight.
