




const today = new Date(); return result.map(record => { let overdueDays = null; let priority = "Not Available"; let slaStatus = "Unknown"; let escalationRequired = "Cannot Determine"; let weekendWarning = "N/A"; if (record.Target_Completion_Date) { const targetDate = new Date(record.Target_Completion_Date); overdueDays = Math.max( 0, Math.floor((today - targetDate) / (1000 * 60 * 60 * 24)) ); // Priority if (overdueDays >= 15) { priority = "🔴 Critical"; } else if (overdueDays >= 7) { priority = "🟠 High"; } else if (overdueDays > 0) { priority = "🟡 Medium"; } else { priority = "🟢 On Track"; } // SLA Status if (overdueDays === 0) { slaStatus = "🟢 Within SLA"; } else if (overdueDays <= 3) { slaStatus = "🟡 Approaching SLA"; } else { slaStatus = "🔴 SLA Breached"; } // Escalation Required escalationRequired = overdueDays > 7 ? "🔴 Escalate Immediately" : "No"; // Weekend Warning const day = targetDate.getDay(); weekendWarning = (day === 0 || day === 6) ? "⚠ Weekend Target" : "Working Day"; } return { "Service Request": record.Name, "Service Request Type": record.Service_Request_Type, "Zone": record.Zone, "Target Completion Date": record.Target_Completion_Date || "Date Not Provided", "Overdue By": overdueDays !== null ? (overdueDays > 0 ? overdueDays + " day(s)" : "Not Overdue") : "Date Not Provided", "SLA Status": slaStatus, "Priority": priority, "Escalation Required": escalationRequired, "Weekend Warning": weekendWarning, "Reason For Delay": record.Reason_For_Delay || "Not Provided", "Field Engineer Name": record["Field_Engineer.Name"]|| "Not Assigned", "Field Engineer Status": record["Field_Engineer.Status"]|| "Engineer Not assigned", "Field Engineer Specialization": record["Field_Engineer.Specialization"]|| "Engineer Not assigned", "Field Engineer Phone": record["Field_Engineer.Phone"] || "Phone Not Available" }; }); |
Derived Field | How the Serializer Calculates It | Example Output |
Overdue By | Calculates the difference between the current date (today) and the Target Completion Date. If the request is not overdue, it displays Not Overdue. If the target completion date is unavailable, it displays Date Not Provided. | 12 days(s) Not OverdueDate |
Priority | Determines the priority based on the calculated Overdue By value. Requests overdue by 15 or more days are marked Critical, those overdue by 7–14 days are marked High, those overdue by 1–6 days are marked Medium, and requests that are not overdue are marked On Track. | 🔴 Critical 🟠 High 🟡 Medium 🟢 On Track |
SLA Status | Uses the calculated overdue duration to determine whether the request is Within SLA, Approaching SLA, or SLA Breached. If the target completion date is unavailable, the serializer returns Unknown. | 🟢 Within SLA 🟡 Approaching SLA 🔴 SLA Breached |
Escalation Required | Checks whether the request has been overdue for more than 7 days. If so, the serializer flags it for escalation; otherwise, it indicates that escalation is not required. | 🔴 Escalate Immediately |
Weekend Warning | Determines the day of the week from the Target Completion Date using getDay(). If the date falls on Saturday or Sunday, the serializer displays a warning; otherwise, it indicates a normal working day. | ⚠ Weekend Target Working Day |
Null Value Handling | Replaces missing values with meaningful messages. | Not Provided Phone Not Available. |



