Calculating End of Useful Life on the alm_hardware table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I am trying to set the end of useful life for assets on the hardware table by using a combination of the created field on the hardware table and the useful life field set on the hardware models table.
I have created the business rule below, but not able to get the 'end of useful life' calculation to work. Any assistance or direction would be helpful:
(function executeRule(current, previous /*null when async*/ ) {
// SKip if no model selected
if (!current.model) return;
// Get the hardware model
var model = new GlideRecord('cmdb_hardware_product_model');
if (!model.get(current.model)) return;
// Skip if not a computer or no useful life set
if (model.model_category != 'Computer' || !model.useful_life) return;
// Calculate end of useful life: created date + useful life months
var endDate = new GlideDateTime(current.sys_created_on);
endDate.addMonth(parseInt(model.useful_life));
current.cmn_end_of_useful_life = endDate;
})(current, previous);
0 REPLIES 0