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
Eric SchragerEric Schrager 

Advanced Apex Superbadge (PDII) Step 6

I'm at Challenge 6 and I'm stuck. I've tested that my code produces the Chatter post to the group, and my AnnouncementQueueable class implements Queuable. I've implemented the excecute() method. But still I get this error:

"Challenge Not yet complete... here's what's wrong: 
Ensure that you implement the Queueable interface in the announcementsQueueable class."

Anyone have an answer? I'd love to complete my PDII before end of year. This feels like a testing defect.
Best Answer chosen by Eric Schrager

All Answers

Sunil SirangiSunil Sirangi
I was struck at challenge 4. The error i am getting is below : "Ensure that you modify the constructProducts method so that it has the correct return type and is not an instance method.". Can you let me know what should be the return type of constructProducts. if required i can share my method code. Thanks.
 
Eric SchragerEric Schrager
I had the same issue on Challenge 4. Pretty sure I solved it by making the method static. 
Sunil SirangiSunil Sirangi
I already updated all the methods to static, but still it did not resolve. I am guessing in my case my return type did not match the expected return type. Can you let me know what is your method return type.
Eric SchragerEric Schrager
Here's my declaration:

public static List<Product2> ConstructProducts(Integer cnt){

Originally, I had done Product2[], which is the same thing but it isn't what the evaluator wanted to see. I had to change it to the above to pass.
Sunil SirangiSunil Sirangi
here is the error i am getting 
"Ensure constructOrders returns a list of size cnt of Order records related to the provided Accounts with all of the required fields populated."
My construct order method is below :

public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Order> ordList = new List<Order>();
        for(Account acc : accts){
            for(Integer i = 0; i<cnt ; i++){                
                Order con =new Order(AccountId = acc.Id,EffectiveDate=system.today(),Status='Draft',PriceBook2Id=Constants.STANDARD_PRICEBOOK_ID,Name='Test'+i);
                ordList.add(con);
                break;
            }
        }
        return ordList;
    }
        
 
Eric SchragerEric Schrager
Here's what you need to fix:
1. Don't loop through the accounts. Just do the Integer loop. Assign each order to accts[i].
2. Make sure you use your Constants class for the value to assign the Status field.
Sunil SirangiSunil Sirangi
Thanks for the reply. But still no luck. Even after the chnages you mentioned it is throwing the same error.
Eric SchragerEric Schrager
This was selected as the best answer
Sunil SirangiSunil Sirangi
@Eric Schrager
Can you share your code of TestDataFactory class. I can cross check to see what exactly is preventing from failing my challenge.
Sunil SirangiSunil Sirangi
Got the mistake. Thanks, you can delete it.
Kevin MurrayKevin Murray
Hey Sunny, how did you fix it?  I'm getting the same error for Step 4, but the code seems to be working fine.  

    public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
        List<Order> orderList = new List<Order>();
        
        for (Integer i=0; i < cnt; i++) {
            orderList.add(new Order (Name = 'test' + i, AccountId = accts[i].id, Status = Constants.DRAFT_ORDER_STATUS, EffectiveDate = System.Today()));
        }
        
        return orderList;
        
        
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
        //  related to the provided Accounts
        //  with all of the required fields populated.
    }
Furkan Alemdaroglu 2Furkan Alemdaroglu 2
"Challenge Not yet complete... here's what's wrong: 
Ensure that you implement the Queueable interface in the announcementsQueueable class." i am getting this error like you  and  your link is not working anymore how did you solve your problem ?