Looping through records and aggregating based on record value

Certified Associate Developer

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
                )
            }
        )
    }
)

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data