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
hi aaquil could try/modify the below code as per your inputs and check whether this is giving the required ouput.
a!localVariables( local!data: { a!map(stdId: 1, crse: 1, status: "Complete"), a!map(stdId: 1, crse: 2, status: "Complete"), a!map(stdId: 1, crse: 3, status: "Complete"), a!map(stdId: 1, crse: 4, status: "Inprogress"), }, local!completeData: a!forEach( items: local!data, expression: if(fv!item.status = "Complete", 1, null) ), length(reject(fn!isnull, local!completeData)) * 25 )