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
You can try following the code and modify it according to your requirements and data:
a!localVariables( local!data: { a!map(stdId: 1, crse: 1, status: "completed"), a!map(stdId: 1, crse: 2, status: "completed"), a!map(stdId: 1, crse: 3, status: "completed"), a!map(stdId: 1, crse: 4, status: "inprogress") }, length( wherecontains("completed", index(local!data, "status")) ) * 25 )