Custom field (multiselect) data deleted on bulk edit #5398

Closed
opened 2025-12-29 19:27:28 +01:00 by adam · 3 comments
Owner

Originally created by @m2martin on GitHub (Sep 21, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.3

Python version

3.9

Steps to Reproduce

  1. Create a custom field of type "multiple selection", add some values and apply it to any content type (e.g. interfaces)
  2. Add some custom values to one or more objects the custom field is applied to
  3. Bulk edit one or more objects where custom values have been applied to
  4. In the bulk edit form click "Apply" without editing anything

Expected Behavior

As the custom fields have not been edited, the values should be preserved.

Observed Behavior

The custom field data is deleted.

Originally created by @m2martin on GitHub (Sep 21, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.3 ### Python version 3.9 ### Steps to Reproduce 1. Create a custom field of type "multiple selection", add some values and apply it to any content type (e.g. interfaces) 2. Add some custom values to one or more objects the custom field is applied to 3. Bulk edit one or more objects where custom values have been applied to 4. In the bulk edit form click "Apply" without editing anything ### Expected Behavior As the custom fields have not been edited, the values should be preserved. ### Observed Behavior The custom field data is deleted.
adam added the type: bugstatus: accepted labels 2025-12-29 19:27:28 +01:00
adam closed this issue 2025-12-29 19:27:28 +01:00
Author
Owner

@m2martin commented on GitHub (Sep 21, 2021):

Form data for custom fields is checked in:

6bc72109c1/netbox/netbox/views/generic.py (L830-L835)

Custom field data is only changed if form field is in nullified_fields or if its data is not empty (None or '').
Actually, the unmodified (empty) form field data is an empty list [], so elif is True and sets custom field data to [].

Tho following line 834 would correct this issue.

elif form.cleaned_data.get(name) not in (None, '', []):
@m2martin commented on GitHub (Sep 21, 2021): Form data for custom fields is checked in: https://github.com/netbox-community/netbox/blob/6bc72109c1004f54595a2179f408055e667881ab/netbox/netbox/views/generic.py#L830-L835 Custom field data is only changed if form field is in `nullified_fields` or if its data is not empty (`None` or `''`). Actually, the unmodified (empty) form field data is an empty list `[]`, so `elif` is `True` and sets custom field data to `[]`. Tho following line [834](https://github.com/netbox-community/netbox/blob/6bc72109c1004f54595a2179f408055e667881ab/netbox/netbox/views/generic.py#L834) would correct this issue. ```python elif form.cleaned_data.get(name) not in (None, '', []): ```
Author
Owner

@m2martin commented on GitHub (Sep 21, 2021):

If my proposal is acceptable, feel free to assign it to me.

@m2martin commented on GitHub (Sep 21, 2021): If my proposal is acceptable, feel free to assign it to me.
Author
Owner

@jeremystretch commented on GitHub (Sep 21, 2021):

Thanks @m2martin. That's definitely the right track, though I think the original implementation can be improved a bit further by evaluating form.changed_data.

@jeremystretch commented on GitHub (Sep 21, 2021): Thanks @m2martin. That's definitely the right track, though I think the original implementation can be improved a bit further by evaluating `form.changed_data`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5398