Document prefilling custom script variables via URL parameters #11739

Closed
opened 2025-12-29 21:49:18 +01:00 by adam · 2 comments
Owner

Originally created by @pheus on GitHub (Oct 16, 2025).

Originally assigned to: @pheus on GitHub.

Change Type

Addition

Area

Customization

Proposed Changes

Clarify that custom script form fields can be initialized from URL query parameters whose names match the script variable names. Include examples for scalar types (e.g., StringVar, IntegerVar) and ObjectVar.

Affected page: docs/customization/custom-scripts.md

Details / Acceptance Criteria:

  • Add a subsection, “Prefilling variables via URL parameters.”
  • Explain that query parameters with names matching script variables are used as initial form values (editable before execution).
  • Document how to prefill ObjectVar using the object’s primary key.
  • Note behavior when the provided object ID is invalid or not visible due to permissions (field remains unprefilled).
  • Provide a concrete example:
    • Example script defining name = StringVar(), count = IntegerVar(), and device = ObjectVar(model=Device).
    • Example URL(s) showing ...?name=Branch42&count=3 and ...?device=1.

Rationale: This capability exists but is currently undocumented; users have asked how to prefill script fields from the URL.

Originally created by @pheus on GitHub (Oct 16, 2025). Originally assigned to: @pheus on GitHub. ### Change Type Addition ### Area Customization ### Proposed Changes Clarify that custom script form fields can be initialized from URL query parameters whose names match the script variable names. Include examples for scalar types (e.g., `StringVar`, `IntegerVar`) and `ObjectVar`. **Affected page:** `docs/customization/custom-scripts.md` **Details / Acceptance Criteria:** - Add a subsection, **“Prefilling variables via URL parameters.”** - Explain that query parameters with names matching script variables are used as initial form values (editable before execution). - Document how to prefill `ObjectVar` using the object’s primary key. - Note behavior when the provided object ID is invalid or not visible due to permissions (field remains unprefilled). - Provide a concrete example: - Example script defining `name = StringVar()`, `count = IntegerVar()`, and `device = ObjectVar(model=Device)`. - Example URL(s) showing `...?name=Branch42&count=3` and `...?device=1`. **Rationale:** This capability exists but is currently undocumented; users have asked how to prefill script fields from the URL.
adam added the status: acceptedtype: documentation labels 2025-12-29 21:49:18 +01:00
adam closed this issue 2025-12-29 21:49:18 +01:00
Author
Owner

@pheus commented on GitHub (Oct 16, 2025):

This docs issue stems from the discussion on #20593, where a user asked about prefilling custom script variables via URL query parameters. The behavior works today but isn’t documented. If this addition is accepted, I’d be happy to contribute a PR to add a short “Prefilling variables via URL parameters” section under Custom Scripts.

@pheus commented on GitHub (Oct 16, 2025): This docs issue stems from the discussion on #20593, where a user asked about prefilling custom script variables via URL query parameters. The behavior works today but isn’t documented. If this addition is accepted, I’d be happy to contribute a PR to add a short “Prefilling variables via URL parameters” section under Custom Scripts.
Author
Owner

@jnovinger commented on GitHub (Oct 18, 2025):

Thanks, @pheus .

@jnovinger commented on GitHub (Oct 18, 2025): Thanks, @pheus .
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11739