Assessment Metric - Script method doesn't seem to record the results. Am I missing something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2018 11:05 PM
Hi,
I'm testing out Assessment functionality and now finding an issue with the Assessment Metric that uses the 'Scripted' Method.
I've successfully tested the functionality of this basic script by writing the values to the system log.
(I've removed the gs.log statements from the code to keep it readable)
// The following variables are available:
// - primary: contains the sys_id of the assessable object to be evaluated
// - string_result: the script sets the display string value for this metric to this variable
// - actual_result: the script sets the actual value for this metric to this variable
// - scaled_result: the script sets the scaled value (used in calculations) for this metric to this variable
//
var gr = new GlideRecord('u_request_for_change');
gs.log('>>> Assessment Metric - started' );
// - primary: contains the sys_id of the assessable object to be evaluated
if (gr.get(primary)); {
//assign random values to the metric var
actual_result = Math.floor((Math.random() * 10) + 1);
string_result = actual_result;
if (actual_result <= 10){
scaled_result = actual_result;
} else if (actual_result > 10){
scaled_result = 10;
}
gs.log('>>> Assessment metric completed');
}
Example of the values below written to the logs:
number= RFC0005622
primary= 17f3b31edb0dd700fcbaf5331d9619ba
actual= 7
string= 7
scaled=7
>>> Assessment metric completed
I've executed the assessment via trigger conditions and seeing values calculated displaying in the system logs as expected but I'm not seeing those values being stored under the Metric Results and can't see how to capture them.
Am I missing something in that script where it's supposed to write to the assessment instance?
current.update maybe .?? ¯\_(ツ)_/¯
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2018 06:13 PM
Any Assessment gurus around?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2018 05:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 10:34 AM
Hi, garfore.
I was able to get my script working. I tinkered with yours, but I was not able to get it running. Here's the meat of the version that is working for me in case you're able to discern what we're doing differently.
var itEffortID = '6de007ff4fb6db40259db3318110c707'; //is sys_id for IT Effort
var itCompID = 'cce3b24c4f475f40259db3318110c7c6'; //is sys_id for IT Complexity
var lowEffort = [200,600,800,1000];
var midEffort = [1500,2500,3000,4000];
var highEffort =[4500,7000,8000,10000];
var maxEffort = [15000,20000,30000,40000];
var scaled_result = 0;
var actual_result = 0;
var itEffortRange = [2.5, 5, 7.5];
var itCompRange = [2.5, 5, 7.5];
var itEffort = 0;
var itComp = 0;
var catQuery = 'source_id='+ primary + '^category=cce3b24c4f475f40259db3318110c7c6' + '^ORcategory=6de007ff4fb6db40259db3318110c707';
var catResults = new GlideRecord('asmt_category_result');
catResults.addEncodedQuery(catQuery);
catResults.query();
while (catResults.next()){
if ((catResults.category == itCompID ) && (itComp == 0)){
itComp = Number(catResults.rating);
}
if ((catResults.category == itEffortID) && (itEffort == 0)){
itEffort = Number(catResults.rating);
}
}
if (itEffort < itEffortRange[0] && itEffort >0){ //assign values for low itEffort
if (itComp < itCompRange[0]){
actual_result = lowEffort[0];
scaled_result = lowEffort[0];
string_result = lowEffort[0];
}
if (itComp >= itCompRange[0] && itComp <itCompRange[1]){
actual_result = lowEffort[1];
scaled_result = lowEffort[1];
string_result = lowEffort[1];
}
if (itComp >= itCompRange[1] && itComp <itCompRange[2]){
actual_result = lowEffort[2];
scaled_result = lowEffort[2];
string_result = lowEffort[2];
}
if (itComp >= itCompRange[2]){
actual_result = lowEffort[3];
scaled_result = lowEffort[3];
string_result = lowEffort[3];
}
}