netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.15k stars 2.58k forks source link

Make customfields multiselect choices related #11993

Closed zacho112 closed 1 year ago

zacho112 commented 1 year ago

NetBox version

v3.4.6

Feature type

Change to existing functionality

Proposed functionality

Currently when using the multi-select options in custom-fields, choice options aren't related when first set. Then means you have to build tools outside Netbox to keep values up-to-date.

This is the case for the implementation in eg Nautobot , you can check their demo site out.

Use case

Making multi-select usable and manageable.

Database changes

No response

External dependencies

No response

jeremystretch commented 1 year ago

Multi-select custom fields are intended to store static values for efficiency. To track related objects, please use the custom object field type.

zacho112 commented 1 year ago

Thanks for the quick reply. But I have a followup question, we have use cases for using custom objects in custom fields. This could eg. be to define interface roles, used in our automation. Currently the best solution is to add tags to the interface named with a key:value.

Fx: Tag: "inteface_role:whatever".

I really hate this idea, because it's ugly, and there's no way for our users to figure out the purpose of these tags. But it get the job done.

We could also add multi-select with objects, and use the tags here, but again, it's not nice either, but it provide more logic for the humans working within Netbox what the purpose of the tag is.

We need this kind of functionality in various places to add extra options used in automation on our objects.

jeremystretch commented 1 year ago

The limitation you're hitting is the need to extend the data model beyond the relationships that already exist. This is usually a sign that it's necessary to either extend the core data model, or introduce a new model via a plugin. (Introducing a model solely to hold choices would be a poor design choice, as it would impose significant performance overhead while delivering very limited value: A choice's attribute would be limited to a single value.)

For your specific use case, I'd argue that it would justify a feature request to introduce an interface role model in NetBox core, as this seems to be a fairly common need. Alternatively, you could write a plugin to introduce your own custom model with whatever additional attributes you may need.