Expose label of custom_field_choice as well as id #11878

Open
opened 2025-12-29 21:51:09 +01:00 by adam · 1 comment
Owner

Originally created by @n3wtype on GitHub (Nov 27, 2025).

NetBox version

v4.4.5

Feature type

Change to existing functionality

Proposed functionality

Ability to access label of custom field choices of custom field of type "Selection" via api call to object to which custom field is assigned.

Use case

Let's say we have following custom field choices assigned to custom field called "cluster" assigned to DCIM->Device. Values of this choices are managed by system external to netbox in the manner where id is some id internal to the external system (for sake of traceability and further synchronization) and Label is actual meaningful value of the entry.

1:cluster1
2:cluster2
3:cluster3

we would like to access value of this field via API call to dcim/device endpoint for further use within standard automation tools which are pulling data from netbox e.g. standard ansible netbox inventory plugin from netbox.netbox collection.

current behaviour

"custom_fields": {
"cluster": 1
}

expected behaviour

"custom_fields": {
"cluster": 1
"cluster__label": "cluster1"
}

As workouround we keep additional custom_field called "cluster_label" which is populated from value of field "cluster" which works fine but requires additional tooling and is prone to inconsistencies.

Database changes

n/a

External dependencies

n/a

Originally created by @n3wtype on GitHub (Nov 27, 2025). ### NetBox version v4.4.5 ### Feature type Change to existing functionality ### Proposed functionality Ability to access label of custom field choices of custom field of type "Selection" via api call to object to which custom field is assigned. ### Use case Let's say we have following custom field choices assigned to custom field called "cluster" assigned to DCIM->Device. Values of this choices are managed by system external to netbox in the manner where id is some id internal to the external system (for sake of traceability and further synchronization) and Label is actual meaningful value of the entry. 1:cluster1 2:cluster2 3:cluster3 we would like to access value of this field via API call to dcim/device endpoint for further use within standard automation tools which are pulling data from netbox e.g. standard ansible netbox inventory plugin from netbox.netbox collection. #### current behaviour "custom_fields": { "cluster": 1 } #### expected behaviour "custom_fields": { "cluster": 1 "cluster__label": "cluster1" } As workouround we keep additional custom_field called "cluster_label" which is populated from value of field "cluster" which works fine but requires additional tooling and is prone to inconsistencies. ### Database changes n/a ### External dependencies n/a
Author
Owner

@jeremystretch commented on GitHub (Dec 4, 2025):

I think this makes sense to implement if we abide by the same pattern already established for built-in choices fields, which present the selected choice as an object with a value and a label:

    "status": {
        "value": "active",
        "label": "Active"
    },

This object is presented only on read access: The field would be written to by passing the raw value as before.

@jeremystretch commented on GitHub (Dec 4, 2025): I think this makes sense to implement if we abide by the same pattern already established for built-in choices fields, which present the selected choice as an object with a value and a label: ```json "status": { "value": "active", "label": "Active" }, ``` This object is presented only on read access: The field would be written to by passing the raw value as before.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11878