1

I have been working towards getting the Salesforce Developer 1 certification and am currently stuck on step 4 of the Apex Specialist Superbadge test. It keeps reporting the following each time I check:

For the positive use case of inserting and updating more than 200 records, it did not produce the expected outcome.

All of my tests that I run locally pass with 100% with 1000 records in test class so I am not sure what I am doing wrong here. I did some research where others have encountered this problem and the proposed solutions were as follows:

  • Ensure the subject of the new case is equal to that of the old case
  • Ensure each new maintenance request has at least 1 related work part

In my test classes I have both of these items covered with full coverage across the board.

The only thing I can think of is that the logic to parse the records resides in the helper and not the trigger. From what I have read across numerous articles on triggers is that triggers should be logic-less, which is why I took this approach.

The trigger is defined as follows:

trigger MaintenanceRequest on Case (before update, after update)
{
    if (Trigger.isAfter && Trigger.isUpdate) 
    {
        MaintenanceRequestHelper.updateWorkOrders(Trigger.oldMap,Trigger.newMap);
    }
}

The helper parses the records based on the defined business criteria, aggregates the results, then submits the records to a private method in the class to handle save results. This method inserts maintenance records and work parts with one dml action for each collection.

All of this works locally and provides 100% code coverage when I run the tests inserting 1000 records each of type case and work part.

I think though that this test expects all of the logic I have in the helper to reside in the trigger.

Is this something anyone else has encountered?

  • No, it expects the trigger to run successfully and produce the expected results. Trailhead doesn't somehow "read" your coffee to figure out if it's right. We'd have to see your helper code or unit test to figure out what's up. – sfdcfox Nov 25 '19 at 2:54
  • :) fair enough. I had originally posted this comment with code but it was taken down by another user. As it turns out, I had a spelling error in the static variable for the case type 'Routine Maintenance' in the helper class. Once I updated that I was able to get past step 4. Also, I'd just like to pass along a thanks to you for all of your posts I have encountered. I've learned quite a bit from all of that. Thank you. – Kevin Nov 25 '19 at 13:52
  • 1
    A good way to debug the code is to run the "check results" with the dev console open - this will enable you to step through the code that checks your code - and see what it's expecting. – Caspar Harmer Nov 26 '19 at 22:02
0

The best answer hear, as it relates to my experience with this question I asked, is to first start looking for simple problems such as issues with spelling or incorrect punctuation instead of assuming larger problems.

Rule out these issues first before spending hours trying to find a problem that might not exist. ugh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.