Allowing Dynamic Custom object filtering using fields set in the current form #7648

Closed
opened 2025-12-29 20:26:26 +01:00 by adam · 8 comments
Owner

Originally created by @damo2929 on GitHub (Feb 16, 2023).

NetBox version

v3.4.3

Feature type

New functionality

Proposed functionality

when creating object custom fields on an object allow setting a dynamic filter field to be set.

example am on virtual machines with a field call build vlan I am linking to vlan. when using the field it shows all vlans and isn't filtered.
whats required is an option when creating the custom field allow me to set a filter that to be set from a field on the current object.

in this case I would like to vfilter vlans that are in the same site as current.site.

however it could be any field thats common between the source and target objects.

Use case

allows more functional use of object and multi-object custom fields by being able to reduce the selection to whats valid and in scope for it's desired use case. in the same way it happens with the native object links.

Database changes

none

External dependencies

none

Originally created by @damo2929 on GitHub (Feb 16, 2023). ### NetBox version v3.4.3 ### Feature type New functionality ### Proposed functionality when creating object custom fields on an object allow setting a dynamic filter field to be set. example am on virtual machines with a field call build vlan I am linking to vlan. when using the field it shows all vlans and isn't filtered. whats required is an option when creating the custom field allow me to set a filter that to be set from a field on the current object. in this case I would like to vfilter vlans that are in the same site as current.site. however it could be any field thats common between the source and target objects. ### Use case allows more functional use of object and multi-object custom fields by being able to reduce the selection to whats valid and in scope for it's desired use case. in the same way it happens with the native object links. ### Database changes none ### External dependencies none
adam added the type: featurepending closurestatus: under review labels 2025-12-29 20:26:26 +01:00
adam closed this issue 2025-12-29 20:26:27 +01:00
Author
Owner

@DanSheps commented on GitHub (Feb 18, 2023):

I feel like this would be blocked by a issue we had opened internally recently, let me try and find it.

Edit: Would be blocked by #10054

@DanSheps commented on GitHub (Feb 18, 2023): I feel like this would be blocked by a issue we had opened internally recently, let me try and find it. Edit: Would be blocked by #10054
Author
Owner

@kkthxbye-code commented on GitHub (Feb 18, 2023):

@DanSheps - I don't think so. If I understand correctly he just wants to apply query_parameters to the api select based on the object. #10054 seeks to address cases where one api select is filtered by another one. That is he doesn't want the user to be able to filter, he wants to specify a filter when creating the custom field, and that filter is dynamic based on the currently displayed object.

Maybe @damo2929 can clarify what the actual intention is.

@kkthxbye-code commented on GitHub (Feb 18, 2023): @DanSheps - I don't think so. If I understand correctly he just wants to apply query_parameters to the api select based on the object. #10054 seeks to address cases where one api select is filtered by another one. That is he doesn't want the user to be able to filter, he wants to specify a filter when creating the custom field, and that filter is dynamic based on the currently displayed object. Maybe @damo2929 can clarify what the actual intention is.
Author
Owner

@jeremystretch commented on GitHub (Feb 27, 2023):

I agree; this doesn't seem like it would be blocked by anything. However I'm also not sure the FR provides sufficient detail. I'd like to see a more thorough description of the proposed functionality.

@jeremystretch commented on GitHub (Feb 27, 2023): I agree; this doesn't seem like it would be blocked by anything. However I'm also not sure the FR provides sufficient detail. I'd like to see a more thorough description of the proposed functionality.
Author
Owner

@roadracer96 commented on GitHub (Feb 28, 2023):

Maybe I can help clarify because I want the same thing.

When creating a Custom Field of type "Object" or "Multiple Objects", add the ability to contextually limit the available objects for selection. The context should be definable on the Custom Field itself and be processed with a logic AND.

This functionality exists for netbox default fields. Example:

If I add a new rack. By default, if I click the "site" pulldown, ALL sites are listed. If I change the region to "Region 1", only sites nested under region 1 are listed.

This gets very difficult when we are talking about say.. interfaces.. If I have 10,000 interfaces defined and have a custom field called "mirror_interface" of type "Multiple Obect" with an Object type of DCIM->Interfaces assigned to DCIM->Interfaces, I may want to restrict the available selections to interfaces on the device I am working with. Or in the SITE the device is in or some other a combination of other filters.. Maybe Only interfaces in a Site that have a specific VLAN on them.

As it stands right now, it is just not possible to select the correct interface because there might be 200 ge-0/0/0s listed. IF we had a multi-select field in Custom Fields called "Filter By", and allowed us to select any other data point as an AND match, we could do this. I would offer that the data points selected in "Filter By" should only be applied if the context in which it is being used contains that data point.

Custom Field "Test" is applied to Racks and Devices and is of type Object with Object type Interface. "Filter By" is set to "Rack" and "Device". In the pulldown under the Rack object, all interfaces of any device in the rack are listed (Ignoring the device filter). In the pulldown under a Device object, only interfaces on that device are listed (ignoring the rack filter, unless the device is in a rack then it would use both)

"As a Netbox User, I need to be able to create custom fields that are populated from data elsewhere in netbox. I need to be able to contextually filter the available choices based upon pre-defined criteria."

@roadracer96 commented on GitHub (Feb 28, 2023): Maybe I can help clarify because I want the same thing. When creating a Custom Field of type "Object" or "Multiple Objects", add the ability to contextually limit the available objects for selection. The context should be definable on the Custom Field itself and be processed with a logic AND. This functionality exists for netbox default fields. Example: If I add a new rack. By default, if I click the "site" pulldown, ALL sites are listed. If I change the region to "Region 1", only sites nested under region 1 are listed. This gets very difficult when we are talking about say.. interfaces.. If I have 10,000 interfaces defined and have a custom field called "mirror_interface" of type "Multiple Obect" with an Object type of DCIM->Interfaces assigned to DCIM->Interfaces, I may want to restrict the available selections to interfaces on the device I am working with. Or in the SITE the device is in or some other a combination of other filters.. Maybe Only interfaces in a Site that have a specific VLAN on them. As it stands right now, it is just not possible to select the correct interface because there might be 200 ge-0/0/0s listed. IF we had a multi-select field in Custom Fields called "Filter By", and allowed us to select any other data point as an AND match, we could do this. I would offer that the data points selected in "Filter By" should only be applied if the context in which it is being used contains that data point. Custom Field "Test" is applied to Racks and Devices and is of type Object with Object type Interface. "Filter By" is set to "Rack" and "Device". In the pulldown under the Rack object, all interfaces of any device in the rack are listed (Ignoring the device filter). In the pulldown under a Device object, only interfaces on that device are listed (ignoring the rack filter, unless the device is in a rack then it would use both) "As a Netbox User, I need to be able to create custom fields that are populated from data elsewhere in netbox. I need to be able to contextually filter the available choices based upon pre-defined criteria."
Author
Owner

@jeremystretch commented on GitHub (May 3, 2023):

NetBox v3.5 introduced a new selector widget (see #10054) that I think would address the need here pretty easily. We should be able to render custom object fields with the selector widget. However, the widget doesn't yet support the selection of multiple objects: That functionality would need to be added as well.

@jeremystretch commented on GitHub (May 3, 2023): NetBox v3.5 introduced a new selector widget (see #10054) that I think would address the need here pretty easily. We should be able to render custom object fields with the selector widget. However, the widget doesn't yet support the selection of multiple objects: That functionality would need to be added as well.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 2, 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 (Aug 2, 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 (Sep 2, 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 (Sep 2, 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.
Author
Owner

@AleksBelytskyi commented on GitHub (Sep 29, 2023):

Will this feature implemented for custom fields? I would like to have it as well.

@AleksBelytskyi commented on GitHub (Sep 29, 2023): Will this feature implemented for custom fields? I would like to have it as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7648