You need to sign in to do that
Don't have an account?
Maurissa Thomas
Apex Specialist Superbadge help
Hello All,
I am currently working on Apex Specialist Superbadge and Im not sure where Im going wrong. Here is the error message I am getting;
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 5003h000002ZNFwAAO; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MaintenanceRequest: execution of BeforeUpdate caused by: System.NullPointerException: Argument cannot be null. Class.MaintenanceRequestHelper.updateWorkOrders: line 19, column 1 Trigger.MaintenanceRequest: line 3, column 1: []
My Apex Helper Code is as follows;
public class MaintenanceRequestHelper {
public static void updateWorkOrders() {
// TODO: Complete the method to update workorders
List<Case> caseList =[
SELECT id, Equipment__c, status, type, subject, vehicle__c, Equipment__r.Maintenance_Cycle__c
FROM Case
Where Status = 'Closed' AND Type IN ('Repair','Routine Maintenance')];
List<Case> newCases = new List<Case>();
for (Case c: caseList){
Case nc = new Case();
nc.Type = 'Routine Maintenance';
nc.subject = 'New Routine Maintenance';
nc.Vehicle__c = c.Vehicle__c;
nc.Equipment__c = c.Equipment__c;
nc.Date_Reported__c = date.today();
nc.Date_Due__c = date.today().addDays(Integer.valueOf(c.Equipment__r.Maintenance_Cycle__c));
newCases.add(nc);
}
insert newCases;
}
}
Please help with an explanation as I'd really like to understand what I need to do to fix this.
Thank you all!
I am currently working on Apex Specialist Superbadge and Im not sure where Im going wrong. Here is the error message I am getting;
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 5003h000002ZNFwAAO; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MaintenanceRequest: execution of BeforeUpdate caused by: System.NullPointerException: Argument cannot be null. Class.MaintenanceRequestHelper.updateWorkOrders: line 19, column 1 Trigger.MaintenanceRequest: line 3, column 1: []
My Apex Helper Code is as follows;
public class MaintenanceRequestHelper {
public static void updateWorkOrders() {
// TODO: Complete the method to update workorders
List<Case> caseList =[
SELECT id, Equipment__c, status, type, subject, vehicle__c, Equipment__r.Maintenance_Cycle__c
FROM Case
Where Status = 'Closed' AND Type IN ('Repair','Routine Maintenance')];
List<Case> newCases = new List<Case>();
for (Case c: caseList){
Case nc = new Case();
nc.Type = 'Routine Maintenance';
nc.subject = 'New Routine Maintenance';
nc.Vehicle__c = c.Vehicle__c;
nc.Equipment__c = c.Equipment__c;
nc.Date_Reported__c = date.today();
nc.Date_Due__c = date.today().addDays(Integer.valueOf(c.Equipment__r.Maintenance_Cycle__c));
newCases.add(nc);
}
insert newCases;
}
}
Please help with an explanation as I'd really like to understand what I need to do to fix this.
Thank you all!
All Answers
For all the Trailhead issues please report it here,
https://trailhead.salesforce.com/en/help?support=home
So that our trailhead support engineers will look into it and get back to you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Regards,
Salesforce Support.