- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:11 PM
How can i update this Business Rule to add 30 days to it??? TIA I also have a script include ClientDateTimeUtils I just didn't know how to write it.
(function executeRule(current, previous /*null when async*/) {
current.retirement_date = current.warranty_expiration;
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:24 PM
var gr = new GlideRecord('alm_hardware');
gr.addEncodedQuery('model_category=81feb9c137101000deeabfc8bcbe5dc4^retirement_dateISEMPTY^warranty_expirationISNOTEMPTY');
gr.query();
while (gr.next()) {
var gdt = new GlideDateTime(gr.warranty_expiration);
gdt.addDaysLocalTime(30);
gr.setValue('retirement_date', gdt.getLocalDate());
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:41 PM
Seems to be a repeat of an earlier request. The above script I provided didn't work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:42 PM
I got an error on it
Evaluator: org.mozilla.javascript.EcmaError: Cannot read property "warranty_expiration" from null Caused by error in script at line 6 3: gr.query(); 4: 5: while (gr.next()) { ==> 6: var gdt = new GlideDateTime(current.warranty_expiration); 7: gdt.addDaysLocalTime(30); 8: gr.setValue('retirement_date', gdt.getDisplayValue()); 9:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:44 PM
can you try now. as you are on background script, current object will not work.
var gr = new GlideRecord('alm_hardware');
gr.addEncodedQuery('model_category=81feb9c137101000deeabfc8bcbe5dc4^retirement_dateISEMPTY^warranty_expirationISNOTEMPTY');
gr.query();
while (gr.next()) {
var gdt = new GlideDateTime(gr.warranty_expiration);
gdt.addDaysLocalTime(30);
gr.setValue('retirement_date', gdt.getLocalDate());
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 01:46 PM
Thank you so much that worked