Skip to content

Filter in custom script? #14578

Closed Locked Answered by candlerb
anders-nc asked this question in Help Wanted!
Dec 21, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

This is described at https://docs.netbox.dev/en/stable/customization/custom-scripts/#objectvar :

To limit the selections available within the list, additional query parameters can be passed as the query_params dictionary

I believe these are the same query params as you pass to the REST API (i.e. the web page using the REST API to populate the list).

we have tagged all Devicetypes depending on type

I would expect you can do (untested):

access_switch_model = ObjectVar(
    description="Access switch model",
    model=DeviceType,
    query_params={
        'tag': 'access-switch',  # this is the *slug*, not the *name*, of the tag
    },
)

See also https://demo.netbox.dev/api/schema/swagg…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@anders-nc
Comment options

Answer selected by anders-nc
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants