Change the Grade Level to Numbers

Prev Next

How to Change the Grade Level to a Number

The OneRoster data type standard for the grades field on the user record is string with specific values expected based on the grade.

The following example was used to convert a grade level of KG to 0 and PR to -1 allowing all other grade level values to remain the same.

function() {
  const grades = SRC.grade;

  if (grades) {

    const grade = grades[0];

      if (grade == 'KG') {
        return '0';
      } 

      else if (grade =='PR') {
        return '-1';
      } 
      
      else {
        return grades;
      }
    
  }
  
  return null;
   
}