-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Cannot filter on Tags in Custom Scripts #18757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've created a simplified example for reference: class TestScript(Script):
assigned_tag = ObjectVar(
model=Tag
)
site = ObjectVar(
model=Site,
query_params={
'tag': '$assigned_tag',
}
) The problem is that the IMO the cleanest approach would be to add a The alternative approach would require really digging into the logic for assigning field values from API responses. Even if a feasible solution was identified, it would have little value beyond this specific scenario as these fields are typically intended to capture the primary keys of related objects. |
IMO the cleanest approach would be to add a I've proposed this functionality in FR #18783. |
Blocked by #18783 |
A |
Deployment Type
Self-hosted
NetBox Version
v4.2.4
Python Version
3.10
Steps to Reproduce
Build this example script in Customization -> Scripts:
Expected Behavior
The dropdown for NNI interface should populate ONLY the interfaces that are tagged with the selection from the Partner dropdown, above.
Observed Behavior
The dropdown for NNI interface is blank
Few other observed behaviors:
My assumption is that $partner is returning something other than the slug as a value.
To validate this, look at the developer tools, you will see this request XHR/fetch after you select a partner in the dropdown:
(IP masked for security)
Taking that url in to the browser does indeed return:
Changing the URL to: https://10.X.X.X/api/dcim/interfaces/?brief=true&limit=100&tag=partnera does return a valid result:
According to the documentation at: https://netboxlabs.com/docs/netbox/en/stable/reference/filtering/#filtering-objects we should be using slugs rather than ids with the API, however, it appears that all the other filters use IDs, so they are at odds with each other.
Changing the query_params from tag to tag_id did not have any effect.
The text was updated successfully, but these errors were encountered: