• Nick Tang 1
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
Dear All 
Merry christmas
I am challenging the step 7 about  the advanced apex superadge 
but there is wrong about it 
Ensure that the page works for existing Order records

User-added image
thanks alot
User-added image
I am curretly doing Advanced Apex Specialist Superbadge..Challenge Not yet complete... here's what's wrong
Does anyone who can help me to fix it 
Dear all 
I create the expense tracker app
but I found when I delete one record ,the comparison as below does not work 
expenses[i]!==expense 
so it will result in the record can not remove from list and it should have been deleted but always display in the page
anyone have ideas?
in fact I know one method is get the latest list in the controller and set the list in the component
I just do not know why the source does not work but the salesforce publish the not work source in the document
whether only me meet this issue?
----------------------​------------------source----​----------------------​----------------------​----------------------
deleteExpense : function(component, expense, callback) {
// Call the Apex controller and update the view in the callback
var action = component.get("c.deleteExpense");
action.setParams({
"expense": expense
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Remove only the deleted expense from view
var expenses = component.get("v.expenses");
var items = [];
for (i = 0; i < expenses.length; i++) {
if(expenses[i]!==expense) {
items.push(expenses[i]);
}
}
component.set("v.expenses", items);
// Other client-side logic
}
});
$A.enqueueAction(action);
Dear
it looks like only product org ,isv and trail org can enable the Dev hub,but in my org I can not find the Dev hub at the lightning Experience ,do I miss something .
I have two questions as below .
1.I have the environment Hub tab so in my opinion,I also have isv environment . and I can enable the dev hub as well , but I can not enable it .
2.I can create the org in my environment hub including test/demo or TrailForce so if it means I can also enable the dev hub at theirs environments .
 
I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	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
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}

 
Dear All 
Merry christmas
I am challenging the step 7 about  the advanced apex superadge 
but there is wrong about it 
Ensure that the page works for existing Order records

User-added image
thanks alot
User-added image
I am curretly doing Advanced Apex Specialist Superbadge..Challenge Not yet complete... here's what's wrong
Does anyone who can help me to fix it 
Sorry for the hijack, I can't create my own post.

Error: 
Ensure that you implement all the pagination methods using the corresponding StandardSetController methods.

I am having an issue with validating the ext.getTotalPages method.
 
/**
     * @name GetTotalPages
     * @description
    **/
    public Integer getTotalPages(){
        return ((Decimal)this.standardSetController.getResultSize() / (Decimal)Constants.DEFAULT_ROWS).round(System.RoundingMode.CEILING).intValue();
    }

Here is my method toSetStandardSetController 
 
private void setStandardSetController() {
        if (this.selectedFamily != Constants.SELECT_ONE && this.selectedFamily != null) {
            this.standardSetController = new ApexPages.StandardSetController(Database.getQueryLocator([
                    SELECT
                            Id,
                            Product2.Name,
                            Product2.Family,
                            Product2Id,
                            UnitPrice,
                            Product2.Quantity_Remaining__c
                    FROM
                            PricebookEntry
                    WHERE Product2.IsActive = true
                    AND Product2.Family =: this.selectedFamily

            ]));
        } else {
            this.standardSetController = new ApexPages.StandardSetController(Database.getQueryLocator([
                    SELECT
                            Id,
                            Product2.Name,
                            Product2.Family,
                            Product2Id,
                            UnitPrice,
                            Product2.Quantity_Remaining__c
                    FROM
                            PricebookEntry
                    WHERE Product2.IsActive = true
            ]));
        }

        this.standardSetController.setPageSize(Constants.DEFAULT_ROWS);
    }

 
Dear all 
I create the expense tracker app
but I found when I delete one record ,the comparison as below does not work 
expenses[i]!==expense 
so it will result in the record can not remove from list and it should have been deleted but always display in the page
anyone have ideas?
in fact I know one method is get the latest list in the controller and set the list in the component
I just do not know why the source does not work but the salesforce publish the not work source in the document
whether only me meet this issue?
----------------------​------------------source----​----------------------​----------------------​----------------------
deleteExpense : function(component, expense, callback) {
// Call the Apex controller and update the view in the callback
var action = component.get("c.deleteExpense");
action.setParams({
"expense": expense
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Remove only the deleted expense from view
var expenses = component.get("v.expenses");
var items = [];
for (i = 0; i < expenses.length; i++) {
if(expenses[i]!==expense) {
items.push(expenses[i]);
}
}
component.set("v.expenses", items);
// Other client-side logic
}
});
$A.enqueueAction(action);
Dear
it looks like only product org ,isv and trail org can enable the Dev hub,but in my org I can not find the Dev hub at the lightning Experience ,do I miss something .
I have two questions as below .
1.I have the environment Hub tab so in my opinion,I also have isv environment . and I can enable the dev hub as well , but I can not enable it .
2.I can create the org in my environment hub including test/demo or TrailForce so if it means I can also enable the dev hub at theirs environments .