# Use custom fields with the inline plugin

**URL:** <https://discourse.beets.io/t/use-custom-fields-with-the-inline-plugin/2050>\
**Category:** Help\
**Created:** [March 13, 2022, 6:10am UTC](https://discourse.beets.io/t/use-custom-fields-with-the-inline-plugin/2050 "2022-03-13T06:10:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kuredant](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kuredant/32/644_2.png) [@Kuredant](https://discourse.beets.io/u/Kuredant)\
**Post date:** [March 13, 2022, 6:10am UTC](https://discourse.beets.io/t/use-custom-fields-with-the-inline-plugin/2050/1 "2022-03-13T06:10:30Z")

</div>

Hi,

I’d like to use the inline plugin with custom file tags.

I read [How to use Custom Fields?](https://discourse.beets.io/t/how-to-use-custom-fields/202) regarding the use of custom tag parsing using plugins.  
I managed to set it up, but I can’t seem to be able to access the custom field from `item_fields`.

Here is my setup:

```auto
$ beet --version
beets version 1.6.0
Python version 3.9.10
plugins: additionalfields, inline

```

`~/.config/beets/config.yaml`:

```nohighlight
directory: ~/Music
pluginpath: ~/.config/beets/plugins
plugins:
    # Custom plugins
    - additionnalfields
    # Built-in plugins
    - inline
paths:
    default: Albums/$albumartist/$album%aunique{}/$disc_and_track $title
item_fields:
    disc_and_track: |
        if custom:
           return custom

        tracknum = f"{track:02}"

        if disctotal > 1:
            return f"{disc:1}-{tracknum}"

        return f"{tracknum}"

```

`~/.config/beets/plugins/additionalfields.py`:

```python
from beets.plugins import BeetsPlugin
from mediafile import (
    MediaField,
    MP4StorageStyle,
    MP3DescStorageStyle,
    StorageStyle,
    ASFStorageStyle,
)

class AdditionalFields(BeetsPlugin):
    def __init__ (self):
        super(). __init__ ()

        field_name = "custom"
        self.add_media_field(
            field_name,
            MediaField(
                StorageStyle(field_name),
                MP3DescStorageStyle(field_name),
                MP4StorageStyle(f"----:com.apple.iTunes:{field_name.upper()}"),
                ASFStorageStyle(field_name),
            ),
        )
        self._log.debug(f"Added field {field_name}")

```

And here are the logs I’m getting when running `beets import -vv`:

```auto
user configuration: /Users/user/.config/beets/config.yaml
data directory: /Users/user/.config/beets
plugin paths: /Users/user/.config/beets/plugins
/Users/user/Library/Python/3.9/lib/python/site-packages/beets/mediafile.py:19: UserWarning: beets.mediafile is deprecated; use mediafile instead
  warnings.warn("beets.mediafile is deprecated; use mediafile instead")
additionalfields: Added field custom
inline: adding item field disc_and_track
Sending event: pluginload
library database: /Users/user/.config/beets/library.db
library directory: /Users/user/Music
Sending event: library_opened
Sending event: import_begin
⋮
beetsplug.inline.InlineError: error in inline path field code:
if custom:
   return custom

tracknum = f"{track:02}"

if disctotal > 1:
    return f"{disc:1}-{tracknum}"

return f"{tracknum}"

NameError: name 'custom' is not defined

```

Is there any way to make this work?
