diff --git a/changelogs/fragments/1346-template-any-field-host.yml b/changelogs/fragments/1346-template-any-field-host.yml
new file mode 100644
index 000000000..fb8aff9fc
--- /dev/null
+++ b/changelogs/fragments/1346-template-any-field-host.yml
@@ -0,0 +1,2 @@
+minor_changes:
+  - Add the ability to use any field to generate the host name in inventory
diff --git a/plugins/inventory/nb_inventory.py b/plugins/inventory/nb_inventory.py
index b06d0fa7f..4b4b18ce2 100644
--- a/plugins/inventory/nb_inventory.py
+++ b/plugins/inventory/nb_inventory.py
@@ -1775,8 +1775,12 @@ def extract_name(self, host):
         # Use virtual chassis name if set by the user.
         if self.virtual_chassis_name and self._get_host_virtual_chassis_master(host):
             return host["virtual_chassis"]["name"] or str(uuid.uuid4())
-        elif self.hostname_field:
+        elif self.hostname_field and self.hostname_field in host["custom_fields"]:
             return host["custom_fields"][self.hostname_field]
+        elif self.hostname_field and (
+            self.hostname_field in host or "." in self.hostname_field
+        ):
+            return self._compose(self.hostname_field, host) or str(uuid.uuid4())
         else:
             return host["name"] or str(uuid.uuid4())