Q1: How many total applications are expected to use this service (including your app)?
Q2: Has the service been made Generally Available (GA) by the cloud service provider?
Q3: Is this service providing a new capability or is it enhancing an existing capability?
Q4: How many developers are expected to use this service?
Q5: Is it expected that this service will increase PROFIT GENERATION?
1
.Yes
, No
where Yes
is a +3
the system property is 3,0
sa_score_[field_name]
. e.g. sa_score_total_applications
.Q1: total_applications
Q2: generally_available_status
1,2
3,0
Q3: service_capability_status
1,2
2,0
Q4: total_developers
1,2,3,4,5
0,0,1,1,1
Q5: profit_generation
1,2,3
1,0,0
Every field has an onChange client script that
assessment_score
field is updated with the returned value.Each onChange client script relies on the Script Include ServiceAssessmentUtil
, which includes two methods:
calculateScore
is the public method called from the GlideAjax in the client script.
_getScore
._getScore
is summed in the variable score
score
is returned_getScore
takes a value (value
) and a field name (fieldName
). - the value of value
is a string, so it is changed to an integer with parseInt()
- the system property name to be retrieved is calculated based on a standard prefix plus the field name value passed in. - The values from the system property are retrieved, then converted to an array using .split(',')
- Since the score values align like 1,2,3...n
we need to take the value
passed in an subtract 1 from it. The array created from the system property value has a zero-based index. So, when we have a value
of 1
we want to get get the corresponding element at array[0]
, not array[1]
. - The value of the element from the array is convert an integer and returnedThis script can be run as a background script to test the logic.
newValue
is changed value from the field in the client script.
calculateScore()
and _getScore()
contain the logic used in the script include.
var newValue = '1'; // score 0
var totalApps = newValue;
var genAvail = '1'; // score: 3
var serviceCap = '2'; // score: 0
var totalDevs = '3'; // score: 1
var profitGen = '3'; // score: 0
var result = calculateScore();
gs.info(result);
function calculateScore() {
var score = 0;
// get the scrore for each field based on the value passed it
var ta = this._getScore(totalApps, 'total_applications');
var ga = this._getScore(genAvail, 'generally_available_status');
var sc = this._getScore(serviceCap, 'service_capability_status');
var td = this._getScore(totalDevs, 'total_developers');
var pg = this._getScore(profitGen, 'profit_generation');
// add up all the results
score = ta + ga + sc + td + pg;
return score;
}
function _getScore(value, fieldName) {
/* declare variables
score is the ultimate result will be returned
convert the value passed in to an integer
calculate the property name from the field name passed in
get the system property
since retrieving score from array, you're getting the element of value - 1.
*/
var score = 0,
value = parseInt(value, 10),
propName = 'x_12350_playground.sa_score_' + fieldName,
propValues = gs.getProperty(propName).split(','),
getValue = value - 1;
// get the value from the array and make it an integer
score = parseInt(propValues[getValue], 10);
return score;
}