Skip to main content
Jane Cando preguntó en #Trailhead
Hi All,

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

Advanced Apex Specialist Superbadge Step 7

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,
17 respuestas
  1. 20 dic 2017, 05:59

    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.