Add selection constraints to custom object fields #6984

Closed
opened 2025-12-29 19:47:27 +01:00 by adam · 4 comments
Owner

Originally created by @darcynz on GitHub (Sep 14, 2022).

NetBox version

v3.3.2

Feature type

New functionality

Proposed functionality

Similar to #9220 we would like to Introduce the ability to allow users to filter objects in UI (by configurable parameters) while assigning 'objects' as custom fields to various models. Eg when selecting Custom Object (interface) the device name is present and can be filtered.

Use case

A sample use-case is a user trying to assign a parent routed 'interface' to a 'vlan group' as a custom field. The drop-down for selection brings up a list of all 'interface objects' on netbox with their 'names' so the user has a a lot of interfaces not knowing which devices those interfaces belong to as the label or name 'GigabitEthernet0/1' likely exists across multiple devices.

A short term fix for this specific use-case could be representing 'interface objects' by '$parent device.name: $interface' or '$interface.id: $interface.name'. A more long-term solution will be giving the option use query_params in the UI. e.g

query_params={ 'device': '$device_id', }

Presently, the correct assignment can only be achieved using a custom script to filter that object in UI and then assign the correct interface.

Database changes

None

External dependencies

None

Originally created by @darcynz on GitHub (Sep 14, 2022). ### NetBox version v3.3.2 ### Feature type New functionality ### Proposed functionality Similar to #9220 we would like to Introduce the ability to allow users to filter objects in UI (by configurable parameters) while assigning 'objects' as custom fields to various models. Eg when selecting Custom Object (interface) the device name is present and can be filtered. ### Use case A sample use-case is a user trying to assign a parent routed 'interface' to a 'vlan group' as a custom field. The drop-down for selection brings up a list of all 'interface objects' on netbox with their 'names' so the user has a a lot of interfaces not knowing which devices those interfaces belong to as the label or name 'GigabitEthernet0/1' likely exists across multiple devices. A short term fix for this specific use-case could be representing 'interface objects' by '$parent device.name: $interface' or '$interface.id: $interface.name'. A more long-term solution will be giving the option use query_params in the UI. e.g query_params={ 'device': '$device_id', } Presently, the correct assignment can only be achieved using a custom script to filter that object in UI and then assign the correct interface. ### Database changes None ### External dependencies None
adam added the type: featurepending closurestatus: under review labels 2025-12-29 19:47:27 +01:00
adam closed this issue 2025-12-29 19:47:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 3, 2022):

This can be partially addressed as part of the proposal defined in #10054. The custom object field dropdown would be extended to include a "selection" button, which would open a modal within the UI allowing the user to apply flexible filtering while selecting the desired object. However, this would not enforce any particular constraints on which objects can be selected.

@jeremystretch commented on GitHub (Oct 3, 2022): This can be partially addressed as part of the proposal defined in #10054. The custom object field dropdown would be extended to include a "selection" button, which would open a modal within the UI allowing the user to apply flexible filtering while selecting the desired object. However, this would not enforce any particular constraints on which objects can be selected.
Author
Owner

@davidgwatkins commented on GitHub (Nov 20, 2022):

Agree, would be very handy to enforce limits to object selection, at least specify permissible values of required fields for a given object model. I am using Object type custom fields to solve some of the discussion on #10558 from the customer perspective. I created circuit type L2 NNI, a VLAN Group associated with a particular NNI, and then a custom field on the VLAN group to link to the actual delivered circuit. Same logic applied to VLAN where providers insist on providing an EVC circuit ID in addition to the UNI at the remote. Could solve with a custom script with the extra validation step, I suppose.

@davidgwatkins commented on GitHub (Nov 20, 2022): Agree, would be very handy to enforce limits to object selection, at least specify permissible values of required fields for a given object model. I am using Object type custom fields to solve some of the discussion on #10558 from the customer perspective. I created circuit type L2 NNI, a VLAN Group associated with a particular NNI, and then a custom field on the VLAN group to link to the actual delivered circuit. Same logic applied to VLAN where providers insist on providing an EVC circuit ID in addition to the UNI at the remote. Could solve with a custom script with the extra validation step, I suppose.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jan 20, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Feb 20, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Feb 20, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6984