function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
salesforce trailheadsalesforce trailhead 

Apex specialist

Hello all,

I have completed creating trigger and helper class, if i close the maintanance request, new maintanence request is gettting created as expected with same vehicle, report date and due date.  But i am getting this errors.

Challenge Not yet complete... here's what's wrong: 
Inserting a new Maintenance Request of type 'Repair' and then closing it did not work as expected. The challenge was NOT expecting to find a Maintenance Request with the same Vehicle and the Status of 'New' and of Type 'Routine Maintenance'. However, it did.

What is the issue.

Thanks.
Best Answer chosen by salesforce trailhead
pconpcon
What I would recommend you do is to just clone the case instead.  This is what I have
 
Product2 equipment = equipmentMap.get(c.Equipment__c);
Date dueDate = Date.today();
            
if (equipment != null) {
    dueDate = dueDate.addDays((Integer) equipment.Maintenance_Cycle__c);
}
   
Case workOrder = c.clone(false, false, false, false);
workOrder.Status = 'New';
workOrder.Type = 'Routine Maintenance;
workOrder.Date_Reported__c = Date.today();
workOrder.Date_Due__c = dueDate;

This was run against an older version of the challenge so your milage may vary.

All Answers

pconpcon
Can you please include a copy of your current trigger and helper class?

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.
pconpcon
What I would recommend you do is to just clone the case instead.  This is what I have
 
Product2 equipment = equipmentMap.get(c.Equipment__c);
Date dueDate = Date.today();
            
if (equipment != null) {
    dueDate = dueDate.addDays((Integer) equipment.Maintenance_Cycle__c);
}
   
Case workOrder = c.clone(false, false, false, false);
workOrder.Status = 'New';
workOrder.Type = 'Routine Maintenance;
workOrder.Date_Reported__c = Date.today();
workOrder.Date_Due__c = dueDate;

This was run against an older version of the challenge so your milage may vary.
This was selected as the best answer
salesforce trailheadsalesforce trailhead
I have cloned and added the things.
Still it showing the same error

User-added image
pconpcon
Can you please re-include your current code?  It looks like your code is firing on a condition that it is not suppose to be.

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.
salesforce trailheadsalesforce trailhead
Hi pcon, 

Please delete your code in the last reply.