• Dharmendra Karamchandani
  • NEWBIE
  • 85 Points
  • Member since 2015
  • Associate Consultant
  • Concretio Apps Pvt Ltd


  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
I got stuck in that error, can someone help me
Error step 7
 
OrderTests Class

@isTest
public class OrderTests {
    
    
    
    public  static Map<String, List<Object>> testData;  
    
    @testSetup 
    static void SetupTestData (){
        
        testData = TestDataFactory.InsertTestData(5);
        
    }
    
      @isTest static void OrderExtension_UnitTest() {
	
	 Order rec = [select id, Status from Order limit 1];
        PageReference pageRef = Page.OrderEdit;
        
        //Test.setCurrentPage(pageRef);
        pageRef.getParameters().put('id',rec.id);
        Test.setCurrentPage(pageRef);
        SetupTestData();
         ApexPages.StandardController sc = new ApexPages.standardController(rec);
        OrderExtension ext = new OrderExtension(sc);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
    @isTest
    static void OrderUpdate_UnitTest (){
        Test.startTest();
        Order rec = [select id, Status from Order limit 1];
        Product2 prod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM Product2 limit 1];
        system.debug('kkk '+prod.Quantity_Ordered__c);
        rec.status = constants.ACTIVATED_ORDER_STATUS;
        Update rec;
        Product2 updatedprod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM Product2 limit 1];
        
        system.debug('kkk '+updatedprod.Quantity_Ordered__c);
        TestDataFactory.VerifyQuantityOrdered(prod,updatedprod,constants.DEFAULT_ROWS);
        Test.stopTest();
    }
    
    
   
    
    
   
}
 
Order Extension Class

/**
 * @name OrderExtension
 * @description This class is provided for you to facilitate the Super Badge
**/
public class OrderExtension {

    public Order orderRecord {get;set;}
    public List<OrderItem> orderItemList {get;set;}
    public String selectedFamily {get;set;}
    public List<chartHelper.chartData> pieData {get;set;}
    public Decimal total {get;set;}
  
    public Map<Id,OrderItem> orderItemMap;
    ApexPages.StandardSetController standardSetController;

    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);
     
    }
    

    public void resetstandardSetController() {
        String query = 'SELECT Name, Product2.Family, Product2.Name, Product2Id, UnitPrice, Product2.Quantity_Remaining__c'
                     + '  FROM PricebookEntry WHERE IsActive = TRUE';

        if (selectedFamily != null && selectedFamily != Constants.SELECT_ONE) {
            query += ' AND Product2.Family = \'' + selectedFamily + '\'';
        }
        query += ' ORDER BY Name';

        standardSetController= new ApexPages.StandardSetController(Database.getQueryLocator(query));
        standardSetController.setPageSize(Constants.DEFAULT_ROWS);
    }

    //ToDo: Implement your own method to populate orderItemList
    //  that you will call after pagination and/or family selection
   public void GetOrderItems() {
        orderItemList = new List<OrderItem>();
        for (SObject obj : standardSetController.getRecords()) {
            PricebookEntry pbe = (PricebookEntry)obj;

            if (orderItemMap.containsKey(pbe.Product2Id)) {
                orderItemList.add(orderItemMap.get(pbe.Product2Id));
            } else {
                orderItemList.add(new OrderItem(
                    PricebookEntryId=pbe.Id,
                    Product2Id=pbe.Product2Id,
                    UnitPrice=pbe.UnitPrice,
                    Quantity=0,
                    Product2=pbe.Product2
                ));
            }
        }
    }


    /**
     * @name OnFieldChange
     * @description
    **/
    public void onFieldChange(){
        //ToDo: Implement logic to store the values changed on the page
        for (OrderItem oi : orderItemList) {
            orderItemMap.put(oi.Product2Id, oi);
        }

        //      and populate pieData
        pieData = null;
        total = 0;
        for (OrderItem oi : orderItemMap.values()) {
            if (oi.Quantity > 0) {
                if (null == pieData) {
                    pieData = new List<chartHelper.ChartData>();
                }
                pieData.add(new chartHelper.ChartData(oi.Product2.Name, oi.Quantity * oi.UnitPrice));
                //      and populate total
                total += oi.UnitPrice * oi.Quantity;
            }

        }

    }

    /**
     * @name SelectFamily
     * @description
    **/
    public void selectFamily(){
        //ToDo: Implement logic to filter based on the selected product family
        resetstandardSetController();
        GetOrderItems();
    }

    /**
     * @name Save
     * @description
    **/
    public void save(){
        //ToDo: Implement logic to save the Order and populated OrderItems
        System.Savepoint sp = Database.setSavepoint();
        try {
            if (null == orderRecord.Pricebook2Id) {
                orderRecord.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            }
            upsert orderRecord;

            List<OrderItem> orderItemsToUpsert = new List<OrderItem>();
            List<OrderItem> orderItemsToDelete = new List<OrderItem>();
            system.debug('@@@@@@@@@@@@@@@#######'+orderItemMap.values());
            for (OrderItem oi : orderItemMap.values()) {
                if (oi.Quantity > 0) {
                    if (null == oi.OrderId) {
                        oi.OrderId = orderRecord.Id;
                    }
                    orderItemsToUpsert.add(oi);
                } else if (oi.Id != null) {
                    orderItemsToDelete.add(oi);
                }
            }
            if(orderItemsToUpsert.size()>0)
            upsert orderItemsToUpsert;
            if(orderItemsToDelete.size()>0)
            delete orderItemsToDelete;
        } catch (Exception e) {
            Database.rollback(sp);
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,Constants.ERROR_MESSAGE));
        }
    }


    /**
     * @name First
     * @description
    **/
    public void First(){      
       standardSetController.first();
       GetOrderItems();
    }

    /**
     * @name Next
     * @description
    **/
    public void Next(){   
       standardSetController.next();
        GetOrderItems();
    }

    /**
     * @name Previous
     * @description
    **/
    public void Previous(){      
        standardSetController.previous();
        GetOrderItems();
    }

    /**
     * @name Last
     * @description
    **/
    public void Last(){
        standardSetController.last();
        GetOrderItems();
    }
  /**
     * @name GetHasPrevious
     * @description
    **/
   public Boolean GetHasPrevious(){
        return standardSetController.gethasprevious();
    }

    /**
     * @name GetHasNext
     * @description
    **/
   public Boolean GetHasNext(){
        return standardSetController.gethasnext();
    }

    /**
     * @name GetTotalPages
     * @description
    **/
   public Integer GetTotalPages(){
       System.debug('=====' + (Integer)Math.ceil(standardSetController.GetResultSize() / (Decimal)Constants.DEFAULT_ROWS));
        return (Integer)Math.ceil(standardSetController.GetResultSize() / (Decimal)Constants.DEFAULT_ROWS);
    }

    /**
    * @name GetPageNumber
     * @description
    **/
    public Integer GetPageNumber(){
        return standardSetController.getpagenumber();
    }

    /**
     * @name GetFamilyOptions
     * @description
    **/
    public List<SelectOption> GetFamilyOptions() {
        List<SelectOption> options = new List<SelectOption>{
            new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE)
        };

        for (Schema.PicklistEntry ple : Constants.PRODUCT_FAMILY) {
            options.add(new SelectOption(ple.getValue(), ple.getLabel()));
        }
        return options;
    }
    

    /**
     * @name QueryOrderRecord
     * @description
    **/
    public static Order QueryOrderRecord(Id orderId){
     return [
        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
            ];
    }

}

 

Hello all

I downloaded and started using the Org w/ the Dreamhouse App pre-built, and went through the trailhead for "Create a Lightning Console App"

https://trailhead.salesforce.com/trails/lex_admin_migration/projects/migrate-a-classic-app-to-lightning-experience-with-declarative-tools/steps/create-a-lightning-console-app

When I get to the end - I can't seem to get past  this error - 
Challenge Not yet complete... here's what's wrong: 
Could not find a Lightning App with the name 'Dreamhouse Console'.

So - that leads me to believe that the default org I have selected in the verify step is wrong, but it isnt (I've tried all of them).  
I have also deleted and rebuilt the console app from scratch, and still nothing.  

Any thoughts or advice?

Hi, 

Can anyone please help me regarding the following problem:

User-added image

Do we have to use custom report type or not, if yes how we have to create that.
How we have to create Total Opp value, Open Opp value, % Open Opp?

Please share your ideas.

Thanks!


Hi Team,

Not able to verify the step 5 of the BUSINESS ADMINISTRATION SPECIALIST SUPERBADGE because of the following error:
Challenge Not yet complete... here's what's wrong:&nbsp; Unwanted fields are still present in the 'Residential Opportunity Page' layout.

I cloned the Utility layout as "Residential Opportunity Page" and modified as per the requirement but still facing the same issue.

Please share some details regarding this, your support will be very helpful for me.

Thanks!

Hi Team,

Not able to verify the step 5 of the BUSINESS ADMINISTRATION SPECIALIST SUPERBADGE because of the following error:
Challenge Not yet complete... here's what's wrong:&nbsp; Unwanted fields are still present in the 'Residential Opportunity Page' layout.

I cloned the Utility layout as "Residential Opportunity Page" and modified as per the requirement but still facing the same issue.

Please share some details regarding this, your support will be very helpful for me.

Thanks!

Hi Team,

Not able to verify the step 5 of the BUSINESS ADMINISTRATION SPECIALIST SUPERBADGE because of the following error:
Challenge Not yet complete... here's what's wrong:&nbsp; Unwanted fields are still present in the 'Residential Opportunity Page' layout.

I cloned the Utility layout as "Residential Opportunity Page" and modified as per the requirement but still facing the same issue.

Please share some details regarding this, your support will be very helpful for me.

Thanks!
Hello,

I am working on superbadge: Advanced Apex Specialist and now got stuck on step3, two errors need some help.

1. Error on "Ensure that the getInventory method is implemented properly." in ChartHelper class. This could work out after remove the static keyword. After the removal, how is it works for lightning component? With @auraEnabled? Or how is it gets called from class Product2Extenstion?

2. Error on "Ensure that the addRows method adds the right number of rows to the productsToInsert list.". Below is the code snippet:
    public void AddRows(){
        for (Integer i=0; i<Constants.DEFAULT_ROWS; i++ ){
            productsToInsert.add(new ProductWrapper());
        }
    }
The definition of "Constants.DEFAULT_ROWS" is:
public static final Integer DEFAULT_ROWS = 5; 
 
What have I missed?  Any help is appreciated.

Helen
I got stuck in that error, can someone help me
Error step 7
 
OrderTests Class

@isTest
public class OrderTests {
    
    
    
    public  static Map<String, List<Object>> testData;  
    
    @testSetup 
    static void SetupTestData (){
        
        testData = TestDataFactory.InsertTestData(5);
        
    }
    
      @isTest static void OrderExtension_UnitTest() {
	
	 Order rec = [select id, Status from Order limit 1];
        PageReference pageRef = Page.OrderEdit;
        
        //Test.setCurrentPage(pageRef);
        pageRef.getParameters().put('id',rec.id);
        Test.setCurrentPage(pageRef);
        SetupTestData();
         ApexPages.StandardController sc = new ApexPages.standardController(rec);
        OrderExtension ext = new OrderExtension(sc);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
    @isTest
    static void OrderUpdate_UnitTest (){
        Test.startTest();
        Order rec = [select id, Status from Order limit 1];
        Product2 prod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM Product2 limit 1];
        system.debug('kkk '+prod.Quantity_Ordered__c);
        rec.status = constants.ACTIVATED_ORDER_STATUS;
        Update rec;
        Product2 updatedprod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM Product2 limit 1];
        
        system.debug('kkk '+updatedprod.Quantity_Ordered__c);
        TestDataFactory.VerifyQuantityOrdered(prod,updatedprod,constants.DEFAULT_ROWS);
        Test.stopTest();
    }
    
    
   
    
    
   
}
 
Order Extension Class

/**
 * @name OrderExtension
 * @description This class is provided for you to facilitate the Super Badge
**/
public class OrderExtension {

    public Order orderRecord {get;set;}
    public List<OrderItem> orderItemList {get;set;}
    public String selectedFamily {get;set;}
    public List<chartHelper.chartData> pieData {get;set;}
    public Decimal total {get;set;}
  
    public Map<Id,OrderItem> orderItemMap;
    ApexPages.StandardSetController standardSetController;

    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);
     
    }
    

    public void resetstandardSetController() {
        String query = 'SELECT Name, Product2.Family, Product2.Name, Product2Id, UnitPrice, Product2.Quantity_Remaining__c'
                     + '  FROM PricebookEntry WHERE IsActive = TRUE';

        if (selectedFamily != null && selectedFamily != Constants.SELECT_ONE) {
            query += ' AND Product2.Family = \'' + selectedFamily + '\'';
        }
        query += ' ORDER BY Name';

        standardSetController= new ApexPages.StandardSetController(Database.getQueryLocator(query));
        standardSetController.setPageSize(Constants.DEFAULT_ROWS);
    }

    //ToDo: Implement your own method to populate orderItemList
    //  that you will call after pagination and/or family selection
   public void GetOrderItems() {
        orderItemList = new List<OrderItem>();
        for (SObject obj : standardSetController.getRecords()) {
            PricebookEntry pbe = (PricebookEntry)obj;

            if (orderItemMap.containsKey(pbe.Product2Id)) {
                orderItemList.add(orderItemMap.get(pbe.Product2Id));
            } else {
                orderItemList.add(new OrderItem(
                    PricebookEntryId=pbe.Id,
                    Product2Id=pbe.Product2Id,
                    UnitPrice=pbe.UnitPrice,
                    Quantity=0,
                    Product2=pbe.Product2
                ));
            }
        }
    }


    /**
     * @name OnFieldChange
     * @description
    **/
    public void onFieldChange(){
        //ToDo: Implement logic to store the values changed on the page
        for (OrderItem oi : orderItemList) {
            orderItemMap.put(oi.Product2Id, oi);
        }

        //      and populate pieData
        pieData = null;
        total = 0;
        for (OrderItem oi : orderItemMap.values()) {
            if (oi.Quantity > 0) {
                if (null == pieData) {
                    pieData = new List<chartHelper.ChartData>();
                }
                pieData.add(new chartHelper.ChartData(oi.Product2.Name, oi.Quantity * oi.UnitPrice));
                //      and populate total
                total += oi.UnitPrice * oi.Quantity;
            }

        }

    }

    /**
     * @name SelectFamily
     * @description
    **/
    public void selectFamily(){
        //ToDo: Implement logic to filter based on the selected product family
        resetstandardSetController();
        GetOrderItems();
    }

    /**
     * @name Save
     * @description
    **/
    public void save(){
        //ToDo: Implement logic to save the Order and populated OrderItems
        System.Savepoint sp = Database.setSavepoint();
        try {
            if (null == orderRecord.Pricebook2Id) {
                orderRecord.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            }
            upsert orderRecord;

            List<OrderItem> orderItemsToUpsert = new List<OrderItem>();
            List<OrderItem> orderItemsToDelete = new List<OrderItem>();
            system.debug('@@@@@@@@@@@@@@@#######'+orderItemMap.values());
            for (OrderItem oi : orderItemMap.values()) {
                if (oi.Quantity > 0) {
                    if (null == oi.OrderId) {
                        oi.OrderId = orderRecord.Id;
                    }
                    orderItemsToUpsert.add(oi);
                } else if (oi.Id != null) {
                    orderItemsToDelete.add(oi);
                }
            }
            if(orderItemsToUpsert.size()>0)
            upsert orderItemsToUpsert;
            if(orderItemsToDelete.size()>0)
            delete orderItemsToDelete;
        } catch (Exception e) {
            Database.rollback(sp);
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,Constants.ERROR_MESSAGE));
        }
    }


    /**
     * @name First
     * @description
    **/
    public void First(){      
       standardSetController.first();
       GetOrderItems();
    }

    /**
     * @name Next
     * @description
    **/
    public void Next(){   
       standardSetController.next();
        GetOrderItems();
    }

    /**
     * @name Previous
     * @description
    **/
    public void Previous(){      
        standardSetController.previous();
        GetOrderItems();
    }

    /**
     * @name Last
     * @description
    **/
    public void Last(){
        standardSetController.last();
        GetOrderItems();
    }
  /**
     * @name GetHasPrevious
     * @description
    **/
   public Boolean GetHasPrevious(){
        return standardSetController.gethasprevious();
    }

    /**
     * @name GetHasNext
     * @description
    **/
   public Boolean GetHasNext(){
        return standardSetController.gethasnext();
    }

    /**
     * @name GetTotalPages
     * @description
    **/
   public Integer GetTotalPages(){
       System.debug('=====' + (Integer)Math.ceil(standardSetController.GetResultSize() / (Decimal)Constants.DEFAULT_ROWS));
        return (Integer)Math.ceil(standardSetController.GetResultSize() / (Decimal)Constants.DEFAULT_ROWS);
    }

    /**
    * @name GetPageNumber
     * @description
    **/
    public Integer GetPageNumber(){
        return standardSetController.getpagenumber();
    }

    /**
     * @name GetFamilyOptions
     * @description
    **/
    public List<SelectOption> GetFamilyOptions() {
        List<SelectOption> options = new List<SelectOption>{
            new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE)
        };

        for (Schema.PicklistEntry ple : Constants.PRODUCT_FAMILY) {
            options.add(new SelectOption(ple.getValue(), ple.getLabel()));
        }
        return options;
    }
    

    /**
     * @name QueryOrderRecord
     * @description
    **/
    public static Order QueryOrderRecord(Id orderId){
     return [
        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
            ];
    }

}

 

Hello all

I downloaded and started using the Org w/ the Dreamhouse App pre-built, and went through the trailhead for "Create a Lightning Console App"

https://trailhead.salesforce.com/trails/lex_admin_migration/projects/migrate-a-classic-app-to-lightning-experience-with-declarative-tools/steps/create-a-lightning-console-app

When I get to the end - I can't seem to get past  this error - 
Challenge Not yet complete... here's what's wrong: 
Could not find a Lightning App with the name 'Dreamhouse Console'.

So - that leads me to believe that the default org I have selected in the verify step is wrong, but it isnt (I've tried all of them).  
I have also deleted and rebuilt the console app from scratch, and still nothing.  

Any thoughts or advice?

I'm doing the simple lightning components challenge and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: QVWBQHAG