- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 03:13 AM
I'm trying to calculate the impacted users based on below format and getting wrong result
Impacted Minutes = Duration * Impacted Users
Impacted Minutes(String Type) = Duration (Duration Type) * Impacted Users (STring Type)
And the result should be displayed in the minutes
(function executeRule(current, previous /*null when async*/) {
var dur = current.duration.getGlideObject().getNumericValue();
dur = dur/1000;
var total = parseInt(current.u_users_impacted)*dur;
// var total = current.u_users_impacted*dur;
var total1=total/60; //convert to mins
current.u_customer_impacted_minutes = total1;
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 04:43 AM
Update the code like below:
(function executeRule(current, previous /*null when async*/) {
var dur = current.duration.getGlideObject().getNumericValue();
dur = dur/1000;
dur = dur/60; // Converting the seconds in minutes
var total = parseInt(current.u_users_impacted)*dur;
// var total = current.u_users_impacted*dur;
//var total1=total/60; //convert to mins
current.u_customer_impacted_minutes = Math.floor(total);
})(current, previous);
This will set 34

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 03:44 AM
hi,
You were converting the whole calculation in the minutes you must convert the seconds to minutes and then you should apply you calculation.
I have modified the script as given below.
(function executeRule(current, previous /*null when async*/) {
var dur = current.duration.getGlideObject().getNumericValue();
dur = dur/1000;
dur = dur/60; // Converting the seconds in minutes
var total = parseInt(current.u_users_impacted)*dur;
// var total = current.u_users_impacted*dur;
//var total1=total/60; //convert to mins
current.u_customer_impacted_minutes = total;
})(current, previous);
Thanks,
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 04:35 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 04:43 AM
Update the code like below:
(function executeRule(current, previous /*null when async*/) {
var dur = current.duration.getGlideObject().getNumericValue();
dur = dur/1000;
dur = dur/60; // Converting the seconds in minutes
var total = parseInt(current.u_users_impacted)*dur;
// var total = current.u_users_impacted*dur;
//var total1=total/60; //convert to mins
current.u_customer_impacted_minutes = Math.floor(total);
})(current, previous);
This will set 34
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 04:47 AM
Checked with 75*17 = 1277 (This result)
But this should be 1275
Why its happening?