Documentation on custom fields in custom links

594 views
Skip to first unread message

Christian S.

unread,
Nov 5, 2020, 1:58:09 AM11/5/20
to NetBox
Dear all,

we're starting to use NetBox in our organisation and love it so far.

We've been working with Custom Links a lot to associate devices with their respective monitoring links or asset DB links. I had a lot of trouble figuring out how to use Custom Field data in Custom Links. I was unable to find information about this in the docs that's why I started looking at  the JSON results of API calls but that didn't help. Only googling helped me to find the information that Custom Fields can be accessed in the Jinja2 templates via the "cf" dictionary. My question is: did I miss the section about data available when using Jinja2 in NetBox? I'd be thankful if you could point me in the right direction.

As a rule of thumb, are all fields that are returned in the API's JSON results e. g. when querying devices available as fields in Jinja2 templates?

Thanks again for providing this excellent software. We've only just scratched the surface of its capabilities and already like it a lot.

Cheers,
Christian

João Lucas B. Macedo

unread,
Nov 19, 2020, 6:51:10 AM11/19/20
to Christian S., NetBox
I use the URL field as "https://{{ obj.primary_ip.address.ip }}/".

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/1d682b4d-d2b9-4d04-893f-68042a63942cn%40googlegroups.com.


--
João Lucas Macedo
Telecom Engineer.

Christian Strauf

unread,
Nov 19, 2020, 7:45:25 AM11/19/20
to NetBox
Hi João,

my question was related to information stored in custom fields and also the general behaviour of NetBox when using standard fields. I gather that you use the ip address from the standard fields -- what about all other standard fields? Are all fields that are available via API usable in Jinja2?

Christian

Armin Bube

unread,
Feb 2, 2021, 7:34:58 AM2/2/21
to NetBox
You can access the Custom Fieds like this:

Text:
{% if obj.cf['webapp_url] is defined %}Web App{% endif %}

URL:
{{ obj.cf['webapp_url] }}

In this case the Custom Link won't be shown if the Custom Field does not exist.

But I did not find anything about it in the offical documentation. I am still wondering how to access tags and services but this is a differtent story for which I will create a new topic.

Cheers,
 Armin

Reply all
Reply to author
Forward
0 new messages