I've been working on code that has been functioning without issue for the past couple of years until recently after a server upgrade. The code is meant to copy student names from a roster to a new date using Visual Studios.
After checking the server logs on AWS, I noticed a multitude of these errors:
- TypeError: Cannot read property 'field_547_raw' of undefined
I'm wondering if anyone has any insight into why this could be happening. Below is the specific snippet of code causing the problem:
//Transform student names into CSV string
let studentNames = _.reduce(inputs.studentDataList, (accumulator, student) => {
accumulator.push(student.field_548_raw[0].identifier);
return accumulator;
}, []).join(', ');
//Retrieve class data and extract the ID and date
let classResponse = await StudentRosterService.getClassFromStudentRosterRecord(inputs.studentDataList[0].id);
try {
classResponse = JSON.parse(classResponse);
} catch (exception) {
return exits.unknownError();
}
let classId = classResponse.records[0].field_547_raw[0].id;
let classDate = classResponse.records[0].field_672;
//Update the student name on the class and date on the Student Roster records
let promises = [];
promises.push(ClassService.putStudentNamesOnClass(studentNames, classId, inputs.userId));
_.forEach(inputs.studentDataList, (studentData) => {
promises.push(StudentRosterService.putClassDateOnStudentRosterRecord(classDate, studentData.id, inputs.userId));
});
Any assistance or insights you can offer would be immensely helpful; feel free to ask any further questions for clarification. Thank you for your time.