From 299bde9653fd03e4159c3f872c471015ad1d9c64 Mon Sep 17 00:00:00 2001 From: Matej Vadnjal Date: Mon, 10 Feb 2025 09:35:11 +0100 Subject: [PATCH] use script form's cleaned data when calling script from CLI so ObjectVar and other field values have proper types in script's data variable --- netbox/extras/management/commands/runscript.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netbox/extras/management/commands/runscript.py b/netbox/extras/management/commands/runscript.py index 847d89396..8b002dbd7 100644 --- a/netbox/extras/management/commands/runscript.py +++ b/netbox/extras/management/commands/runscript.py @@ -81,12 +81,17 @@ class Command(BaseCommand): logger.error(f'\t{field}: {error.get("message")}') raise CommandError() + # Remove extra fields from ScriptForm before passng data to script + form.cleaned_data.pop('_schedule_at') + form.cleaned_data.pop('_interval') + form.cleaned_data.pop('_commit') + # Execute the script. job = ScriptJob.enqueue( instance=script_obj, user=user, immediate=True, - data=data, + data=form.cleaned_data, request=NetBoxFakeRequest({ 'META': {}, 'POST': data,