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
Rahul Agrawal 43Rahul Agrawal 43 

Advanced Apex Specialist Superbadge Step 7

Hi All,

While working on the Advanced Apex Specialist Superbadge Step 7 I am facing a weird issue.
User-added image

The OrderExtension class is alreeady containing a variable of StandardSetController and in the OrderEdit page orderItemList is getting iterated.
But Salesforce doesn't support standardsetcontroller for OrderItem.

Hence getting the error: List controllers are not supported for OrderItem

Could anyone please help me, how to solve this issue.

Thanks,
Rocco SorrentinoRocco Sorrentino
Hi Rahul, I'm getting another error:
Challenge Not yet complete... here's what's wrong:  Ensure that you implement all the pagination methods using the corresponding StandardSetController methods.
https://developer.salesforce.com/forums?id=9060G0000005O6OQAU
 
ravi reddy 68ravi reddy 68
Hi All,
While working with step 2 , I am getting following error.
Challenge Not yet Complete....ensure that trigger call correct method .Can anybody help me find out issues with ordertrigger .
Thanks in advance

 
ravi reddy 68ravi reddy 68
Also, I have issues with OrderHelper. I was wondering if anybody could help me clear step 2 with Orderhelper and ordertrigger?
Rahul Agrawal 43Rahul Agrawal 43

Hi Zachery,

I changed the reference of StandardListController to PriceBookeEntry but now showing the error to: Challenge Not yet complete... here's what's wrong:  Ensure that you implement all the pagination methods using the corresponding StandardSetController methods.

In the OrderQueryRecord method: I added a condition to fetch all active pricebookentries for the order item:

public static Order QueryOrderRecord(Id orderId){
            SELECT Id, AccountId, EffectiveDate, Name, Status, Pricebook2Id,
                (
                    SELECT Id, OrderId, Quantity, UnitPrice, PricebookEntryId, Product2Id,
                         Product2.Name, Product2.Family, Product2.Quantity_Remaining__c
                    FROM OrderItems where PricebookEntry.isActive = true
                )
            FROM Order WHERE Id = :orderId

Below I assigned StandardController to PriceBookeEntry
Constructor: 
public OrderExtension(ApexPages.StandardController standardController){
        orderRecord = (Order)standardController.getRecord();
        orderItemMap = new Map<id,OrderItem>();
        if ( orderRecord.Id != null ){
            orderRecord = queryOrderRecord(orderRecord.Id);
        }
        orderItemList = new List<OrderItem>();
        OrderItemList.addAll(orderRecord.OrderItems);
        set<Id> p2ids = new set<Id>();
        for(OrderItem oitem : OrderItemList){
            p2ids.add(oitem.PriceBookEntryId);
        }
        List<PriceBookEntry> p2List = new List<PriceBookEntry>();
        if(p2Ids.size()>0){
            p2List = [select id from PriceBookEntry where id IN: p2Ids];
        }
        standardSetController = new ApexPages.StandardSetController(p2List);
        standardSetController.setPageSize(Constants.DEFAULT_ROWS);
    }

Still not able to fix this issue.
 

Rocco SorrentinoRocco Sorrentino
Hi Raul,

I suggest to inspect the Log inside the Developer Console and right click and click "View Raw Log" to see the anonymous apex code that is asserting your code.
You'll be able to check the errors. For example:

from the developer console:
13:04:31:053 EXCEPTION_THROWN [4]|System.AssertException: Assertion Failed: ext.getTotalPages() did not return the expected result.

and on Trailhead:
Challenge Not yet complete... here's what's wrong: 
Ensure that you implement all the pagination methods using the corresponding StandardSetController methods.
ravi reddy 68ravi reddy 68
Hi All, I am working on advanced apex specialist Challenge 2 .I got error message " Challenge Not yet complete... here's what's wrong: Ensure that you loop through a query that aggregates the OrderItems related to the Products in the ProductMap keyset. " Please share Orderhelper class to check where i am doing mistake.
Abhishek-tandonAbhishek-tandon
Hi Zachery/Rocco,

Could you share your order extension class, my pagination is not working fine, also in case of edit, do we need show existing product only?
Abhishek-tandonAbhishek-tandon
Hi Zachery,

Is GetOrderItems is a new method created by you and in this you are preparing list of order items based on pricebookentries in the current standardsetcontroller current records.
Wacław SmagaWacław Smaga
Hi guys

I'm getting: System.AssertException: Assertion Failed: ext.getHasNext() did not return the expected result.
When I check in the UI, it works fine, buttons are disabled in right momets.

My getHasNext() method:
public Boolean GetHasNext(){
     return standardSetController.getHasNext();
}
Any ideas?
AMIT SINGH 2375AMIT SINGH 2375
Hi All,

Anyone can post the Apex class code here?
ravi reddy 68ravi reddy 68
@Amit Singh I have the same issue with standardsetcontroller pagination methods. 
ravi reddy 68ravi reddy 68
@Amit singh and Abhishek-tandon
Make sure  you have less than 15 products in trailhead org and check .Delete products manually if you have more than 15.you can get getTotalpages()working by having lessthan 15 which you confirm it in raw logs.You will no longer get error message "Ensure that you implement all the pagination methods using the corresponding StandardSetController methods."
Nirmallya_GhoshNirmallya_Ghosh
I am getting "Challenge Not yet complete... here's what's wrong: 
Ensure that you implement all the pagination methods using the corresponding StandardSetController methods" please help
 
Mayur_112Mayur_112
@Nirmallya,
After clicking on check challenge, check your developer console debug logs, some assert condition must be failing if it is regarding gettotalpages()  then check the count of pricebookentry records ideally it should be 12 and the number of pages should be 12/5 = 3. Delete any extra records.
Emilien Guichard 40Emilien Guichard 40
Hi there,

I deleted all the extra products I created but I'm still facing this error :

Assertion Failed: ext.getHasNext() did not return the expected result.

Any piece of advice ?
Thanks a lot.
 
AYANAYAN
Hi All , 

I'm facing issue in Advance Apex step 7 code.

Issue: Challenge Not yet complete... here's what's wrong: 
Ensure that you implement all the pagination methods using the corresponding StandardSetController methods.

can any body share all the code for step 7
Oleg PogrebnyakOleg Pogrebnyak
If solutions above didn't help for you (as for me), ensure that Product2 and PricebookEntry IsActive fields are true.
For example query:
SELECT Name, Product2.Family, Product2.Name, Product2Id, UnitPrice, Product2.Quantity_Remaining__c  FROM PricebookEntry WHERE IsActive = TRUE ORDER BY Name
should return 12 rows.