- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2025 01:14 AM
Hi,
i work on this problem for a couple of hours already but i still can not figure out a solid approach.
In cmdb_hardware_product_model we have Notebooks with Manufactuer HP and Name "HP Elite x360 830 13 inch G11 2-in-1 Notebook PC" this Creates a display_name "HP HP Elite x360 830 13 inch G11 2-in-1 Notebook PC". Our Procurement Guys dont want that HP HP. This Displayname gets created via OOTB BR "calculate display_name" on cmdb_model.
function _calculateDisplayName(){
global.ModelUtils.calculateDisplayName(current);
}
_calculateDisplayName();So i thought i'm super smart and do something like this:
function _calculateDisplayName() {
var mfg = current.manufacturer.name + "";
var modelName = current.name + "";
if (mfg === "HP" && modelName.startsWith("HP ")) {
var newName = modelName.substring(3).trim();
if (newName !== modelName) {
current.setValue('name', newName);
}
}
global.ModelUtils.calculateDisplayName(current);
}
_calculateDisplayName();What now happens, i get a stripped display name only with one "HP" as expected, but every Endpoint discovered gets its own hardware model, so suddenly i have a ton of duplicate HW Models each with one single asset/ci linked.
What is going on here? Did i miss some crucial step in the Asset/Ci creation?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2025 04:01 AM - edited 10-07-2025 04:06 AM
Let's say i have "HP Elite x360 830" as Model Name, when i change it to "Elite x360 830" next time discovery gets data it will create a new hardware model with name "HP Elite x360 830" and link the asset from my changed Model entry to the new one created by discovery.
But i fixed it anyway myself by directly writing to display_name and skip OOTB function when HP HP is found.
function _calculateDisplayName() {
var mfg = current.manufacturer.name + "";
var modelName = current.name + "";
if (mfg === "HP" && modelName.startsWith("HP ")) {
var newName = modelName.substring(3).trim();
current.setValue('display_name', "HP " + newName);
return;
}
global.ModelUtils.calculateDisplayName(current);
}
_calculateDisplayName();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2025 02:41 AM
This is interesting - thanks for sharing. This means that the discovery takes the model name from field which contains manufacturer, or there is something else going on which creates the model name as if it's the displayed model name. Good that you've found a workaround, which unfortunately is a common way to solve problems in ServiceNow platform.
