- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 11:26 AM
I am trying to change the value of a duration field after the change record has been inserted. It should count how many affected CI are associated to the change record then change the current value of the duration field by multiplying the current value to number of CIs found.
I have this business rule in place, but doesn't appear to be working:
setEstimatedTime();
function setEstimatedTime() {
var aciRecord = new GlideRecord('task_ci');
aciRecord.addQuery('task', current.sys_id);
aciRecord.query();
gs.log('Affected CI Records found: ' + aciRecord.getRowCount());
var ciRowCount = aciRecord.getRowCount();
var eTime = current.u_estimated_time.dateNumericValue();
eTime = eTime * ciRowCount;
current.u_estimated_time.setDateNumericValue(eTime);
}
Any suggestions?
Many thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 12:29 AM
Thanks March, that did the trick here is the updated script for anyone to re-utilize;
setEstimatedTime();
function setEstimatedTime() {
var aciRecord = new GlideRecord('task_ci');
aciRecord.addQuery('task', current.sys_id);
aciRecord.query();
gs.log('Affected CI Records found: ' + aciRecord.getRowCount());
var ciRowCount = aciRecord.getRowCount();
var eTime = current.u_time_per_unit.dateNumericValue();
eTime = Number(eTime) * ciRowCount;
current.u_estimated_time.setDateNumericValue(eTime);
}
I've had to create a new duration field to store the original time value then multiply it by the number of row returned from the query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 02:40 PM
Try replacing
eTime = eTime * ciRowCount;
with
eTime = Number(eTime) * ciRowCount;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 12:29 AM
Thanks March, that did the trick here is the updated script for anyone to re-utilize;
setEstimatedTime();
function setEstimatedTime() {
var aciRecord = new GlideRecord('task_ci');
aciRecord.addQuery('task', current.sys_id);
aciRecord.query();
gs.log('Affected CI Records found: ' + aciRecord.getRowCount());
var ciRowCount = aciRecord.getRowCount();
var eTime = current.u_time_per_unit.dateNumericValue();
eTime = Number(eTime) * ciRowCount;
current.u_estimated_time.setDateNumericValue(eTime);
}
I've had to create a new duration field to store the original time value then multiply it by the number of row returned from the query.