How to populate overall status of status report based on schedule, cost ,resources, scope

Datha prasadred
Tera Contributor

How to populate overall status of status report based on schedule, cost ,resources, scope and also selection of overall red if  choices like options 1 ,2 3  present  in overall status section i have a requirement like below.

 

Dathaprasadred_0-1728637369827.png

 

I  used below  before/after  business rule but not working please help on this..

var redCount = 0;
var yellowCount = 0;

// Get the category statuses
var categories = [gr.schedule, gr.cost, gr.resources, gr.scope]; // Replace with the actual field names

// Count red and yellow categories
for (var i = 0; i < categories.length; i++) {
if (categories[i] == 'red') {
redCount++;
} else if (categories[i] == 'yellow') {
yellowCount++;
}
}

// Logic for setting overall status based on the selected red choice
switch (gr.u_overall_red_if) { // Replace 'overall_red_choice' with the actual field name
case '1':
if (redCount >= 1) {
gr.overall_health = 'red'; // Replace 'overall_health' with the actual field name
}
break;

case '2':
if (redCount >= 1 || yellowCount >= 2) {
gr.overall_health = 'red';
}
break;

case '3':
if (redCount >= 1 || yellowCount >= 3) {
gr.overall_health = 'red';
}
break;

case '4':
if (redCount >= 1 || yellowCount >= 4) {
gr.overall_health = 'red';
}
break;

default:
gr.overall_health = 'not red'; // Or whatever default status you prefer
}

// Update the record
gr.update();
}

 



1 REPLY 1

Datha prasadred
Tera Contributor

Hello Team,

 

Can anyone help on this requirement please.