updating company name doesn't update display name

brkelly
Kilo Expert

When updating company names, the display names of products do not update, the business rules appear to be set to run on update.

I am specifically looking at SW model, but I notice this with HW model as well.

The default scripts - below are set to run on insert, and update. I think these are the only business rules populating the Display name.   ??

I have updated the Company name - didn't update display name.

Then I made a change to a model, to force an update, and still the display name didn't update.

I even tried updating on 'Query' on both business rule scripts below, which had no visible effect.

The only way I was able to update the company (model manufacturer) was to change it to a different company and change it back.   This makes any change to a company name pretty annoying.

------Calculate Display name--------------------------------------------------------------

var values = [current.manufacturer.getDisplayValue(), current.name, current.version, current.edition];

var displayName = '';

if (values[1].toLowerCase().indexOf(values[0].toLowerCase()) != -1 && 'true'.equals(gs.getProperty('glide.cmdb_model.display_name.shorten')))

  values[0] = '';

for (var i = 0; i < values.length; i++){

  if (values[i] != undefined && values[i] != '')

  displayName += ' ' + values[i];

}

current.display_name = displayName.trim();

-------Update Asset Display name-------------------------------------------------------------

updateAssets(current);

function updateAssets(current) {

  var asset = new GlideRecord("alm_asset");

  asset.addQuery("model", current.sys_id);

  asset.query();

  while (asset.next()) {

  if (new AssetUtils().calculateDisplayName(asset))

  asset.update();

  }

}

------------------------------------------------------------------------------------------------------------

Any help would be greatly appreciated. I feel like I must be looking in the wrong place.

Brian

7 REPLIES 7

brkelly
Kilo Expert

Ok, I now understand that the Manufacturer field reference is not triggering the field update, and the system was not designed to do this.



We are updating the reference table, Company, not the model itself.  



Is there a way for the Model table to update when the reference field changes instead of current.name?


Community Alums
Not applicable

Brian,


You are correct. The change does not propagate through all of the possible places that might be used in calculated fields. The direct references are "updated" because they are just pointers and there isn't really anything to update.


To update the Display name would take a modification of the fields associated with the Display name (A change of the Manufacturer or Name)   in the Model record or something to rerun the script.



As I think about it, there may be some situations when you do not want to change the Display name, despite the change in Manufacturer's name. For example, many years ago, Adobe acquired Macromedia. You might consider leaving Macromedia Dreamweaver 3.0 as the Display name, even though Adobe is listed as the Manufacturer.



Ben


brkelly
Kilo Expert

There are many instances where a related record matters.   I think references to Company and Users may be candidates for this type of capability.



For every user field on an asset, model, group, ci, there should be a system to manage them.


Community Alums
Not applicable

Brian,


A couple thoughts here:


  • Remember that one of the powerful things about references is that you change the source, everything that points to it is automatically uses the new information. Because the reference field uses the sysid, no change is made on the records that reference this item (hence the reason calculated fields like Display name do not update).
  • What you describe in your system to manage them is more about stale data than correct data. For example, is this User still assigned this Asset?
  • You could use Data Certification   for regular validation that data is correct.