How to configure the text field as described below
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2025 09:44 AM - edited ‎08-14-2025 11:02 AM
Each time a Residual Risk calculation is performed on a Change Request, Create a new Business Rule concatenated text field is generated specifying the value of each factor and how it contributes to the scores
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2025 07:15 PM
// Define the variables as per the example
var ab = '0 to 3:0,4 to 6:+50,7 and above:+100'; // call properties
var jn = [1, 2]; // Example array with length 2 // call grouplist field
// Function to get the output based on the length of jn and the ranges in ab
function getOutput(length, rangesStr) {
var segments = rangesStr.split(',');
for (var i = 0; i < segments.length; i++) {
var segment = segments[i];
var parts = segment.split(':');
var rangePart = parts[0].trim();
var value = parts[1].trim();
var min, max;
// Parse the range
if (rangePart.indexOf('and above') !== -1) {
// Handle '7 and above' case
min = parseInt(rangePart.split(' and above')[0].trim());
max = Infinity;
} else if (rangePart.indexOf('to') !== -1) {
// Handle '0 to 3' case
var minMax = rangePart.split(' to ');
var minStr = minMax[0].trim();
var maxStr = minMax[1].trim();
min = parseInt(minStr);
max = parseInt(maxStr);
} else {
// Skip invalid segments
continue;
}
// Check if length falls within the range
if (length >= min && (max === Infinity || length <= max)) {
return rangePart + ' (' + value + ')';
}
}
// If no range matches
return 'No matching range';
}
// Get the length of jn
var len = jn.length;
// Get and log the output
var output = getOutput(len, ab);
gs.print(output); // For length 2, outputs: 0 to 3 (0)
// Additional test cases
gs.print(getOutput(2, ab)); // Outputs: 4 to 6 (+50)
gs.print(getOutput(8, ab)); // Outputs: 7 and above (+100)
gs.print(getOutput(10, ab)); // Outputs: 7 and above (+100)