Allow adding constraints on custom fields/links #6439

Closed
opened 2025-12-29 19:40:45 +01:00 by adam · 1 comment
Owner

Originally created by @abhi1693 on GitHub (May 4, 2022).

NetBox version

v3.2.2

Feature type

Data model extension

Proposed functionality

Add a JSON field to the custom fields/links model which can allow a user to filter where the field should be displayed on the UI. As it stands today, when you add a custom field which maps to a Device, it is displayed for all devices on their detail page. It may not be desirable for people to display the same field for every device they have as one can have various different types/roles of devices.

The JSON field (like the one provided in object permission) can be used to define in what conditions the field should be displayed for both view and edit. When left empty, it should work just the way it does today.

Use case

I have several networks as well as ESXi under devices. I have a custom field namely p_sync (boolean field) which only applies to all devices with the role Router, however, the field shows up on every device page. Similarly, I have a field which only applies to ESXi, but it shows for network devices as well.

I have mentioned only 2 fields in my example, but in reality, we have at least 4 fields for each device role we have that only apply to them. But without a way to filter these, every field shows on every device clustering the UI. As of writing the issue, on each device page, we have 28 custom fields which are ideally not desirable and make an end-user thinks there may be something wrong with the fields for not showing the data.

Database changes

I believe a JSON field named constraints should be needed on both custom fields and links

External dependencies

None

Originally created by @abhi1693 on GitHub (May 4, 2022). ### NetBox version v3.2.2 ### Feature type Data model extension ### Proposed functionality Add a JSON field to the custom fields/links model which can allow a user to filter where the field should be displayed on the UI. As it stands today, when you add a custom field which maps to a Device, it is displayed for all devices on their detail page. It may not be desirable for people to display the same field for every device they have as one can have various different types/roles of devices. The JSON field (like the one provided in object permission) can be used to define in what conditions the field should be displayed for both view and edit. When left empty, it should work just the way it does today. ### Use case I have several networks as well as ESXi under devices. I have a custom field namely `p_sync` (boolean field) which only applies to all devices with the role `Router`, however, the field shows up on every device page. Similarly, I have a field which only applies to ESXi, but it shows for network devices as well. I have mentioned only 2 fields in my example, but in reality, we have at least 4 fields for each device role we have that only apply to them. But without a way to filter these, every field shows on every device clustering the UI. As of writing the issue, on each device page, we have 28 custom fields which are ideally not desirable and make an end-user thinks there may be something wrong with the fields for not showing the data. ### Database changes I believe a JSON field named `constraints` should be needed on both custom fields and links ### External dependencies None
adam added the type: featurestatus: duplicate labels 2025-12-29 19:40:45 +01:00
adam closed this issue 2025-12-29 19:40:46 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 4, 2022):

Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #8560 for further discussion.

@jeremystretch commented on GitHub (May 4, 2022): Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #8560 for further discussion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6439