New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.. Absent Member..
Absent Member..
2332 views

SLO duration type - Calculation End of the month

Hi experts,

I need to implement SLO with specific duration type to the end of current month. I have not find any information except that two other options are hardcoded and cannot be changed(End of Business day, End of Business week).

I've found some kind of work around - to use Duration in record. To use this option I should write duration to some field to probsummary table when incident is opened (no problem on that). I've tried to count this duration (according to built-in schedules) with RAD function calendar.calc.interval from JS, but I haven't received any return values and errors. Maybe you can point on my mistakes in JS code below.

function calcduration(){
var rteReturnValue = new SCDatum();
var rteNames = new SCDatum();
var rteValues = new SCDatum();
var result = new SCDatum();
result.setType(3);

rteNames.setType(8);
rteNames.push("times,1");
rteNames.push("times,3");
rteNames.push("prompt");
rteNames.push("name");
rteNames.push("times,2");

var start = new SCDatum();
start.setType(3);
start = system.functions.tod();

var end = new SCDatum();
end.setType(3);
end = system.functions.val("22/06/2011 00:00:00", 3);

var sched = new SCDatum();
sched.setType(2);
sched = "9x5";

rteValues.setType(8);
rteValues.push(start);
rteValues.push(end);
rteValues.push(sched);
rteValues.push("");
rteValues.push(result);

system.functions.rtecall("callrad",
rteReturnValue,
"calendar.calc.interval",
rteNames,
rteValues,
false);
print(rteValues);
print(rteReturnValue);
}

This function returns no errors. It's just gives 0 results:
[C++ object SCDatum] - 0
[C++ object SCDatum] - {'12.05.2011 10:40:12', '22.06.2011 00:00:00', "9x5", "", '00:00:00'}

I've tried lots of different input values, all kind of time formats, but result remains the same.
Thank you in advance for your time.

Regards.
0 Likes
5 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

I'll appreciate any approach. Any ideas about variable in SLO duration field?
Regards.
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

I have not found how to make calendar.calc.interval RAD get to work. Therefore, I have used calendar.calc.interval.fc RAD in JavaScript. In case someone will need such functionality from JS I am posting it here.

function CalcInterval(start, end, calend){

var rteReturnValue = new SCDatum();
var Names = new SCDatum();
var Vals = new SCDatum();
var rec = new SCFile("probsummary");

Names.setType(8);//type array
Vals.setType(8);//type array

Names.push("file");
Names.push("name");
Names.push("times,1");
Names.push("times,2");
Names.push("prompt");

Vals.push(rec);
Vals.push("time.spent"); //any Date/time field
Vals.push(start);
Vals.push(end);
Vals.push(calend);

var rc = system.functions.rtecall("callrad",
rteReturnValue,
"calendar.calc.interval.fc", //RAD app name
Names,
Vals,
false);

return rec.time_spent;
}

Usage:

var dur = CalcInterval(system.functions.tod(), system.functions.val("17/05/2011 18:00:00",3), "9x5");
var d = new XMLDate(new Date(dur));
print(d.toSCDuration());

Regards.
Highlighted
Absent Member.
Absent Member.

Really useful post! Works great and I took advantage from it when updating the duration of an already closed clocks without restarting and restopping it. Thank you!

0 Likes
Highlighted
Fleet Admiral
Fleet Admiral

Many thanks for sharing this.

0 Likes
Highlighted
Cadet 3rd Class Cadet 3rd Class
Cadet 3rd Class

At the risk of appearing a bit thick, could I please ask for a slightly more in-depth explaination of how to use this script?

In particular, what is the 'usage' part of the script used for and where does it go?

Many thanks.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.