• vijay kanth reddy satti
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hello, I'm getting the following error:

Challenge Not yet complete... here's what's wrong: 
The 'projectRef__c' field is not configured correctly as an Indirect Lookup field.

I've googled it and tried every solution but I can't fix it.

Here is how I've got configured the External Object:

User-added image

Something weird is that I'm in the last step and I have no data on the Project object. I've done Validate and Sync but nothing.

Thanks!!
Hello,
While solving challenge 8 I am getting an error:- 
Challenge Not yet complete... here's what's wrong: 
Ensure that orderTrigger and orderHelper are still working as specified in the earlier challenge.
Please let me know what I am doing wrong else paste the correct code here.
My code goes as follows-:

CLASS- OrderTests

@isTest
public class OrderTests {
    @testSetup 
    public static void SetupTestData() {     
            TestDataFactory.InsertTestData(3);      
    }
    
   @isTest
    public static void OrderUpdate_UnitTest (){
        Test.startTest();
        
        List<Product2> originalProduct=[Select Quantity_Ordered__c from Product2 where Name like 'ProductConstruction%'];
        
        List<Order> ord=new List<Order>();
        List<Order> testOrders=[Select status from Order where status='Draft'];
        System.debug('originalPro '+originalProduct);
        System.debug('Ordertest orders '+testOrders);
        
        for(Order o:testOrders){
            
            o.Status=Constants.ACTIVATED_ORDER_STATUS;
            ord.add(o);
        }
        System.debug('OrderTests 21 '+ord);
        update ord;
        List<Product2> updatedProduct=OrderHelper.pr; 
        //System.debug(updatedProduct.get(0)+' '+originalProduct.get(0));
           TestDataFactory.VerifyQuantityOrdered(originalProduct.get(0), updatedProduct.get(0), (Integer)OrderHelper.temp.get(0)); 
        Test.stopTest();
    }
    @isTest
    public static void OrderExtension_UnitTest (){
        Test.startTest();
        
        Account ac=new Account();
        ac.Name='Test1';
        insert ac;
        
        Contract ct=new Contract();
        ct.AccountId=ac.Id;
        ct.StartDate =date.today();
        ct.Status='Draft';
        ct.ContractTerm=4; 
        insert ct;
        
        Order obj=new Order();
        obj.AccountId=ac.Id;
        obj.EffectiveDate=date.today();
        obj.ContractId=ct.Id;
        obj.Status='Draft';
        obj.Name='OrderName';
       
        insert obj;
        
        ApexPages.StandardController sc = new ApexPages.StandardController(obj);
        
        OrderExtension cc=new OrderExtension(sc);
        cc.SelectFamily();
        cc.OnFieldChange();
        cc.Save();
        cc.First();
        cc.Next();
        cc.Previous();
        cc.Last();
        cc.GetHasPrevious();
        cc.GetHasNext();
        cc.GetTotalPages();
        cc.GetFamilyOptions();
        Test.stopTest();
    }
}

CLASS- prouct2Tests
@isTest (seeAllData=true)
private class Product2Tests {

    /**
     * @name product2Extension_UnitTest
     * @description UnitTest for product2Extension
    **/ 
    static TestMethod void Product2Extension_UnitTest(){
        Test.startTest();
           PageReference pageRef = Page.Product2New;
           Test.setCurrentPage(pageRef);
          
        
        ApexPages.StandardController controller =new Apexpages.StandardController(new Product2());
            Product2Extension ext = new Product2Extension(controller);
            ext.addRows();
            ext.save();
            System.assertEquals(Product2Extension.productsToInsert.size(), Constants.DEFAULT_ROWS);
        
         
         //if(addValue.equals('Add'))
                  //System.assertEquals(Product2Extension.productsToInsert.size(), 2*Constants.DEFAULT_ROWS);
        
        Integer i=0;
        for(Product2Extension.ProductWrapper pr: Product2Extension.productsToInsert){
            if (String.isBlank(pr.productRecord.Name) || pr.productRecord.Name==null){
                pr.productRecord.Name='Product'+i;
            }
               
            if(String.isBlank(pr.productRecord.Family) ||  pr.productRecord.Family==null ){
                pr.productRecord.Family='Side';
            }
                  
            if(pr.productRecord.IsActive==false){
                pr.productRecord.IsActive=true;
            }
            if(pr.productRecord.Initial_Inventory__c==null){
                pr.productRecord.Initial_Inventory__c=15;
            }
            i++;
                   
        }
        PageReference p=ext.save();
        List<Product2> queryResults=[Select Name,IsActive,Initial_Inventory__c from Product2 where Initial_Inventory__c=15 and IsActive= true and Family='Side'];
                Test.stopTest();
        System.assertEquals(queryResults.size(), 5);
        System.debug(Product2Extension.productsToInsert.size());       

    }
    static void Product2Trigger_UnitTest(){
        Test.startTest();
        
        Product2 p=new Product2();
        p.Name='TestProduct';
        p.Family='Side';
        p.IsActive=true;
        p.Quantity_Ordered__c =100;
        p.Initial_Inventory__c =10;
        insert p;
        
        p.Quantity_Ordered__c=200;
        update p;
            
        Test.stopTest();
    }

}

CLASS - OrderHelper
public without sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static List<Product2> pr=new List<Product2>();
    public static List<Decimal> temp;
    public static void AfterUpdate(List<Order> newList, List<Order> oldList){
        Set<Id> orderIds = new Set<Id>();
        for ( Integer i=0; i<newList.size(); i++ ){
            if ( newList[i].Status == Constants.ACTIVATED_ORDER_STATUS && oldList[i].Status == Constants.DRAFT_ORDER_STATUS ){
                orderIds.add(newList[i].Id);
            }
        }
        System.debug('New Order '+newList);
        System.debug('Old Order '+oldList);
        System.debug('OrderIDS '+orderIds);
        OrderHelper.RollUpOrderItems(orderIds);
    }

    /**
     * @name RollUpOrderItems
     * @description Given a set of Activated Order ids, query the child Order Items and related Products to calculate Inventory levels
     * @param Set<Id> activatedOrderIds
     * @return void
    **/
    public static void RollUpOrderItems(Set<Id> activatedOrderIds){
        List<OrderItem> oi=[Select Id, Product2Id ,AvailableQuantity from OrderItem where OrderId IN:activatedOrderIds];
        Map<Id,Product2> productMap=new Map<Id,Product2>();
        //ToDo: Declare a Map named "productMap" of Ids to Product2 records

        //ToDo: Loop through a query of OrderItems related to the activatedOrderIds
        for(OrderItem ord:oi){
            Product2 p=[Select Id,Name, Quantity_Ordered__c , Quantity_Remaining__c from Product2 where Id=: ord.Product2Id ];
            productMap.put(ord.Product2Id, p);
         }
         
        
          AggregateResult[] groupedResults =[Select Product2Id,SUM(Quantity) from OrderItem where Product2Id IN : productMap.keySet() group by Product2Id];
        
        for(AggregateResult ag:groupedResults){
             Product2 p= productmap.get((Id)ag.get('Product2Id'));
               p.Quantity_Ordered__c =(Double)ag.get('expr0');
                temp.add(p.Quantity_Ordered__c);
               pr.add(p);
        }
        System.debug('orderHelper'+pr+' '+activatedOrderIds+' '+groupedResults);
        update pr;
            //ToDo: Populate the map with the Id of the related Product2 as the key and Product2 record as the value
            
        //ToDo: Loop through a query that aggregates the OrderItems related to the Products in the ProductMap keyset

        //ToDo: Perform an update on the records in the productMap
    }

}

Thanks in advance
Shubham Nandwana
I am beginner :  Not able to solve Trailhead challange for-Developer Beginner :Process Automation-Automate Basic Business Processes with Process Builder
"
Create a process to update child record when the parent is updated.
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.
NOTE: You may have to deactivate the validation rule for the Contacts object (created from a previous challenge) in order to complete this challenge."

 What I had tried 
Deleted validation rule on contact  from previous challange.
 Using Process builder created new Process with below details
Object: Account
Criteria:'Update Address' with condidtion

Field: selected shipping street, city, state,postalcode and country
Operator: Ischanged
Type: boolean
value: true

Condition:
Any condition met (OR)

 For Immediate action
Action name: Mailing address change
Records: Account.contacts
Criteria for Updating Records:No criteria—just update the records!

Set new field values for the records you update:

Field: selected Mailing street, city, state,postalcode and country
Type: Reference
value:  selected shipping street, city, state,postalcode and country

 after this saved and activated. So Once I check challange got below error:
"Challenge Not yet complete... here's what's wrong:
An update to an account record failed to update the mailing address fields of all child contact records. Make sure that the process is correct and that it is activated."

So Please help.





 
hi
i am new to salesforce platform.
Install a simple Apex class, write unit tests that achieve 100% code coverage for the class, and run your Apex tests.The Apex class to test is called 'VerifyDate', and the code is available here. Copy and paste this class into your Developer Edition via the Developer Console.
'VerifyDate' is a class which tests if a date is within a proper range, and if not will return a date that occurs at the end of the month within the range.
The unit tests must be in a separate test class called 'TestVerifyDate'.
The unit tests must cover scenarios for all lines of code included in the Apex class, resulting in 100% code coverage.
Run your test class at least once (via the Developer Console) before attempting to verify this challenge.

In the above challege i am not able to write a 'TestVerifyDate' class. I dont unsertstand how to write it for a date.
plz help..