- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 06:41 AM
Hi all,
I need a solution for the following scenario:
1. Asset display name is a combo of a asset tag and model.
2. Related CI's name is the same as the asset
3. I need a business rule that will adapt the CI's display name when user changes asset's model.
As you can see below; I have change the model and so asset's display name changed but CI remains the same.
I also want to be sure that this name will be updated only when the asset's display name will be the same as the CI.
If it is different nothing should happen.
Thanks for all the tips!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 10:24 AM
Hi @dev_K ,
This is doable, please find the below BR-
(function executeRule(current, previous /*null when async*/) {
// display name combining asset and model
var DisplayName = current.asset_tag + ' - ' + current.model_id.getDisplayValue();
// Update the display name
if (current.display_name != DisplayName) {
current.display_name = DisplayName;
current.update();
}
if (current.model_id != previous.model_id || current.asset_tag != previous.asset_tag) {
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addQuery('asset', current.sys_id);
ciGr.query();
while (ciGr.next()) {
if (ciGr.name == previous.display_name || ciGr.name == current.display_name) {
ciGr.name = DisplayName;
ciGr.update();
}
}
}
})(current, previous);
Modify the above based on other validations as per your requirement.
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 10:24 AM
Hi @dev_K ,
This is doable, please find the below BR-
(function executeRule(current, previous /*null when async*/) {
// display name combining asset and model
var DisplayName = current.asset_tag + ' - ' + current.model_id.getDisplayValue();
// Update the display name
if (current.display_name != DisplayName) {
current.display_name = DisplayName;
current.update();
}
if (current.model_id != previous.model_id || current.asset_tag != previous.asset_tag) {
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addQuery('asset', current.sys_id);
ciGr.query();
while (ciGr.next()) {
if (ciGr.name == previous.display_name || ciGr.name == current.display_name) {
ciGr.name = DisplayName;
ciGr.update();
}
}
}
})(current, previous);
Modify the above based on other validations as per your requirement.
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 12:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 02:48 PM
I think you'll need a business rule that is triggered when an Asset's Model changes and updates the corresponding CI's model.
(function executeRule(current, previous /*null when async*/) {
var gr_ci = new GlideRecord('cmdb_ci');
if(gr_ci.get(current.getValue('ci'))){
gr_ci.setWorkflow(false);
gr_ci.setValue('model_id', current.getValue('model'));
gr_ci.update();
}
})(current, previous);
Hope this helps.