Skip to content

[Feature]: Adding and relating Custom Fields #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bststr opened this issue Mar 27, 2025 · 5 comments
Closed

[Feature]: Adding and relating Custom Fields #259

bststr opened this issue Mar 27, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@bststr
Copy link

bststr commented Mar 27, 2025

NetBox version

v4.2.3

Feature type

Add a function

Proposed functionality

Would be great, if you can create custom fields for Access Lists and Rules.
Also it would be great, if you can use ACLs and Rules as Related object type if you create a Custom Field with type "Object" or "Multiple Objects".

This should also work with the API.

In the API response the custom_fields key is listed. But you cannot create Custom Fields with and for ACLs and rules.

Thank you!

Use case

Safe Custom Data within an ACL or Rule Object.

External dependencies

No response

@bststr bststr added the enhancement New feature or request label Mar 27, 2025
Copy link

Thanks for opening this Issue! We really appreciate the feedback & testing from users like you!

@pheus
Copy link
Contributor

pheus commented Mar 27, 2025

Hi @bststr,

Thanks for opening this issue!

Could you provide a step-by-step guide to reproduce the behavior you're experiencing? I attempted to replicate the issue, but everything seems to be working as expected.

I was able to:

  • Create a custom field of type Text on an AccessList via both the Web UI and API.
  • Create a custom field of type Multiple Objects on a Device, with AccessList as the related object.

Custom Field on AccessList (Text) – API Request:

{
  "object_types": [
    "netbox_acls.accesslist"
  ],
  "type": "text",
  "name": "role",
  "label": "Role",
  "group_name": "string",
  "description": "string",
  "required": false,
  "unique": false,
  "ui_visible": "always",
  "ui_editable": "yes",
  "is_cloneable": true,
  "default": "standard"
}

Response:

{
  "id": 2,
  "url": "http://netbox/api/extras/custom-fields/2/",
  "display_url": "http://netbox/extras/custom-fields/2/",
  "display": "Role",
  "object_types": [
    "netbox_acls.accesslist"
  ],
  "type": {
    "value": "text",
    "label": "Text"
  },
  "related_object_type": null,
  "data_type": "string",
  "name": "role",
  "label": "Role",
  "group_name": "string",
  "description": "string",
  "required": false,
  "unique": false,
  "search_weight": 1000,
  "filter_logic": {
    "value": "loose",
    "label": "Loose"
  },
  "ui_visible": {
    "value": "always",
    "label": "Always"
  },
  "ui_editable": {
    "value": "yes",
    "label": "Yes"
  },
  "is_cloneable": true,
  "default": "standard",
  "related_object_filter": null,
  "weight": 100,
  "validation_minimum": null,
  "validation_maximum": null,
  "validation_regex": "",
  "choice_set": null,
  "comments": "",
  "created": "2025-03-27T20:57:02.863726Z",
  "last_updated": "2025-03-27T20:57:02.863751Z"
}

Custom Field on Device (Multiple Objects – Related to AccessList) – API Request:

{
  "object_types": [
    "dcim.device"
  ],
  "type": "multiobject",
  "name": "acl_assignment",
  "label": "ACL Assignment",
  "required": false,
  "unique": false,
  "ui_visible": "always",
  "ui_editable": "yes",
  "is_cloneable": true,
  "related_object_type": "netbox_acls.accesslist"
}

Response:

{
  "id": 4,
  "url": "http://netbox/api/extras/custom-fields/4/",
  "display_url": "http://netbox/extras/custom-fields/4/",
  "display": "ACL Assignment",
  "object_types": [
    "dcim.device"
  ],
  "type": {
    "value": "multiobject",
    "label": "Multiple objects"
  },
  "related_object_type": "netbox_acls.accesslist",
  "data_type": "array",
  "name": "acl_assignment",
  "label": "ACL Assignment",
  "group_name": "",
  "description": "",
  "required": false,
  "unique": false,
  "search_weight": 1000,
  "filter_logic": {
    "value": "loose",
    "label": "Loose"
  },
  "ui_visible": {
    "value": "always",
    "label": "Always"
  },
  "ui_editable": {
    "value": "yes",
    "label": "Yes"
  },
  "is_cloneable": true,
  "default": null,
  "related_object_filter": null,
  "weight": 100,
  "validation_minimum": null,
  "validation_maximum": null,
  "validation_regex": "",
  "choice_set": null,
  "comments": "",
  "created": "2025-03-27T21:02:18.838176Z",
  "last_updated": "2025-03-27T21:02:18.838204Z"
}

From my testing, custom fields seem to be functioning correctly for Access Lists and Rules. If you're encountering a different issue, could you please share the exact steps you took? That way, we can investigate further.

Looking forward to your response!

@bststr
Copy link
Author

bststr commented Mar 27, 2025

Hello @pheus ,

thanks for investigating.
I will respond on monday again with further information, because I am out of office until monday and cannot check with our Netbox installation.

So far I can say, that I couldn't select Access Lists for custom fields in the gui, neither for object nor as related object type when selecting object as custom field type. So i thought it wasn't implemented so far. That's the reason for feature request and not bug.
But please, let me check again and I will response as soon as possible.

Thanks and best regards!

@pheus
Copy link
Contributor

pheus commented Mar 27, 2025

Hi @bststr,

Thanks for your response! No worries—take your time, and we’ll be happy to look into it further once you’ve had a chance to check your NetBox installation.

You may be encountering this issue"Models from plugin not showing up for custom field selection (#17836)".

Let us know what you find on Monday!

Wishing you a great weekend.

@bststr
Copy link
Author

bststr commented Mar 31, 2025

Hello @pheus,

I checked the issue you linked and found this comment from phlpr:

I had exactly the same issue with a custom-developed plugin. So, I searched for the error in the source code of our plugin.
After some testing, I noticed that no custom fields from plugins that are loaded after the 'netbox_attachments' plugin are being loaded.
I haven't pinpointed the exact error yet, but if you move 'netbox_attachments' to the last position, the other plugins work fine. Are you also using 'netbox_attachments'?

Although we do not use netbox_attachments plugin, I reordered the plugins in our configuration, and now the netbox_acls plugin is listed for custom fields.

I don't know which plugin we use is responsible for this behavior, but it could be netbox_floorplan, because it also has to do with attachments. I'm not sure.

Our plugins are now listed in the following order:

netbox_reorder_rack
netbox_acls
netbox_dns
netbox_topology_view
netbox_floorplan

With this order, everything works.

Thank you very much, pheus, for this tip and your support!

Have a good start to the week!

@bststr bststr closed this as completed Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants