• Deepak Mali
  • 5 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

I am facing below error while trying to verify Step 8-
Error: Please ensure that product2Extension and its methods are still working as specified in the earlier challenge.

Code below:
public class Product2Extension {

    public List<ProductWrapper> productsToInsert {get;set;}

    public Product2Extension(ApexPages.StandardController controller){
        productsToInsert = new List<ProductWrapper>();
    public List<SelectOption> GetFamilyOptions() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE));
        for(PickListEntry eachPicklistValue : Constants.PRODUCT_FAMILY) {
            options.add(new SelectOption(eachPicklistValue.getValue(), eachPicklistValue.getLabel()));
            return options;
    public void AddRows(){
        for (Integer i=0; i<Constants.DEFAULT_ROWS; i++ ){
            productsToInsert.add(new ProductWrapper());

    public List<ChartHelper.ChartData> GetInventory(){
        return ChartHelper.GetInventory();

    public PageReference Save(){
        SavePoint sp = Database.setSavepoint();
        Integer insertedCount = 0;
        try {
            List<Product2> newProducts = new List<Product2>();
            List<PriceBookEntry> pbeList = new List<PriceBookEntry>();
            List<ProductWrapper> filteredProductWrappers = new List<ProductWrapper>();
            for(ProductWrapper eachPW : productsToInsert) {
                if(!String.isBlank(eachPW.productRecord.Name) && !String.isBlank(eachPW.productRecord.Family) && 
                   eachPW.productRecord.Family!=Constants.SELECT_ONE && eachPW.productRecord.isActive &&
                   eachPW.pricebookEntryRecord.UnitPrice!=null && eachPW.productRecord.Initial_Inventory__c!=null && 
                   eachPW.productRecord.Initial_Inventory__c!=0 && eachPW.pricebookEntryRecord.UnitPrice!=0) {
            for(ProductWrapper eachPW : filteredProductWrappers) {
            Database.SaveResult[] productSaveResults = Database.insert(newProducts, false);
            for(Integer i=0; i<productSaveResults.size(); i++) {
                if(productSaveResults[i].isSuccess()) {
                    PriceBookEntry pbe = filteredProductWrappers[i].pricebookEntryRecord;
                    pbe.Product2Id = productSaveResults[i].getId();
                    pbe.IsActive = true;
                    pbe.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            Database.SaveResult[] pbeSaveResults = Database.insert(pbeList, false);
            //If successful clear the list and display an informational message
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,insertedCount + ' Inserted'));
            productsToInsert.clear();   //Do not remove
            addRows();  //Do not remove
        catch (Exception e){
            System.debug('Exception occured:'+e.getMessage());
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, Constants.ERROR_MESSAGE));            
        return null;
    public class ProductWrapper {
        public Product2 productRecord {get;set;}
        public PriceBookEntry pricebookEntryRecord {get;set;}
        public ProductWrapper() {
            productRecord = new Product2();
            pricebookEntryRecord = new PricebookEntry();
The challenge is:

You've been given a requirement to keep Contact addresses in sync with the Account they belong to. Use Process Builder to create a new process that updates all child Contact addresses when the address of the Account record is updated. This process:Can have any name.
Must be activated.
Must update Contact mailing address fields (Street, City, State, Post Code, Country) when the parent Account shipping address field values are updated.

I start with Accounts when records is created or edited.
Filter criteria where accounts shipping address (street, city, state, zip code) is changed (used "or" logic).

I am stuck on the next step "add action".  I started with action type "Update Records".
On objects, I can't seem to change Accounts to Contacts.  Why?