Looping through records and aggregating based on record value
I want to loop through a list of 'Course' CDT and increment the local variable named progresspercent by 25 each time I encounter a Course with status "completed". E.g. a student is enrolled in 4 courses and 3 of them have "completed" status, the progresspercent variable should be 75 in this case. Following is a snippet of my code and a picture of the output I am getting.
Can you please help me figure out how I can do this?
a!localVariables(
local!progresspercent: 0,
{
local!progresspercent,
a!forEach(
items: rule!ID_GetCourses(ri!collegeid),
expression: {
local!progresspercent + if(
fv!item['recordType!ID course.fields.status'] = "completed",
25,
0
)
}
)
}
)
/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/Screenshot-2024_2D00_06_2D00_14-at-6.30.24_2F20_PM.png
