• Paras Prajapati
  • NEWBIE
  • 34 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hello Guys,

I have been stuck on Challenge two of the Advanced Apex Specialist superbadge. Getting the following error:
Challenge 2 Error.

Below are my trigger and class:
/**
 * @name orderTrigger
 * @description
**/
trigger OrderTrigger on Order (after update) {

    if (Trigger.new != null) {
        OrderHelper.AfterUpdate(Trigger.new, Trigger.old);
    } 

}
 
public with sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static void AfterUpdate(List<Order> newList, List<Order> oldList){
        Set<Id> activatedOrderIds = new Set<Id>();

        //Create list of OrderIds
        for ( Integer i=0; i<newList.size(); i++ ){
            if ((newList[i].Status == Constants.ACTIVATED_ORDER_STATUS && newList[i].ActivatedDate != null) 
                && oldList[i].Status == Constants.DRAFT_ORDER_STATUS){
                activatedOrderIds.add(newList[i].Id);
            }
        }

        RollUpOrderItems(activatedOrderIds);
    }

    /**
     * @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){
        //ToDo: Declare a Map named "productMap" of Ids to Product2 records
        Map<Id, Product2> productMap = new Map<Id, Product2>();
        Set<Id> productIds = new Set<Id>();

        //ToDo: Loop through a query of OrderItems related to the activatedOrderIds
        List<OrderItem> items = [SELECT Id, Product2Id, Quantity
                                FROM OrderItem
                                WHERE OrderId In :activatedOrderIds];
        for(OrderItem oi : items) {
            //ToDo: Populate the map with the Id of the related Product2 as the key and Product2 record as the value
            productIds.add(oi.Product2Id);
        }

        productMap = new Map<Id, Product2>([SELECT Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);

        //ToDo: Loop through a query that aggregates the OrderItems related to the Products in the ProductMap keyset
        for(OrderItem oi : items) {
            if(productMap.containsKey(oi.Product2Id)) {
                productMap.get(oi.Product2Id).Quantity_Ordered__c += oi.Quantity;
            }
        }

        //ToDo: Perform an update on the records in the productMap
        update productMap.values();
    }

}

I would appreciate any leads or help in resolving this. Thanks!

Regards​
Hello Guys,

I have been stuck on Challenge two of the Advanced Apex Specialist superbadge. Getting the following error:
Challenge 2 Error.

Below are my trigger and class:
/**
 * @name orderTrigger
 * @description
**/
trigger OrderTrigger on Order (after update) {

    if (Trigger.new != null) {
        OrderHelper.AfterUpdate(Trigger.new, Trigger.old);
    } 

}
 
public with sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static void AfterUpdate(List<Order> newList, List<Order> oldList){
        Set<Id> activatedOrderIds = new Set<Id>();

        //Create list of OrderIds
        for ( Integer i=0; i<newList.size(); i++ ){
            if ((newList[i].Status == Constants.ACTIVATED_ORDER_STATUS && newList[i].ActivatedDate != null) 
                && oldList[i].Status == Constants.DRAFT_ORDER_STATUS){
                activatedOrderIds.add(newList[i].Id);
            }
        }

        RollUpOrderItems(activatedOrderIds);
    }

    /**
     * @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){
        //ToDo: Declare a Map named "productMap" of Ids to Product2 records
        Map<Id, Product2> productMap = new Map<Id, Product2>();
        Set<Id> productIds = new Set<Id>();

        //ToDo: Loop through a query of OrderItems related to the activatedOrderIds
        List<OrderItem> items = [SELECT Id, Product2Id, Quantity
                                FROM OrderItem
                                WHERE OrderId In :activatedOrderIds];
        for(OrderItem oi : items) {
            //ToDo: Populate the map with the Id of the related Product2 as the key and Product2 record as the value
            productIds.add(oi.Product2Id);
        }

        productMap = new Map<Id, Product2>([SELECT Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);

        //ToDo: Loop through a query that aggregates the OrderItems related to the Products in the ProductMap keyset
        for(OrderItem oi : items) {
            if(productMap.containsKey(oi.Product2Id)) {
                productMap.get(oi.Product2Id).Quantity_Ordered__c += oi.Quantity;
            }
        }

        //ToDo: Perform an update on the records in the productMap
        update productMap.values();
    }

}

I would appreciate any leads or help in resolving this. Thanks!

Regards​

Hi,

I am trying to update orderTrigger on challenge 2, and  I am getting below error:
User-added image

Please find my trigger and helper class below. Any help would be highly appreciated.

orderTrigger:

/**
 * @name orderTrigger
 * @description
**/
trigger orderTrigger on Order (after update) {
    public Set<Id> orderIds = new Set<Id>();
    if(Trigger.new != null){
    	orderIds = OrderHelper.AfterUpdate(Trigger.new, Trigger.old);    
    }
    
    OrderHelper.RollUpOrderItems(orderIds);
    
}

OrderHelper:
public with sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static Set<Id> 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 == 'Activate' && oldList[i].Status == 'Draft' ){
                orderIds.add(newList[i].Id);
            }
        }
        return 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){
        Map<Id, Product2> productMap;
        Set<Id> product2Ids = new Set<Id>();
        List<OrderItem> orderItems = [SELECT Id, Quantity, Product2Id FROM OrderItem WHERE OrderId IN:activatedOrderIds];
        for(OrderItem item :orderItems){
            product2Ids.add(item.Product2Id);
        }
        productMap = new Map<Id, Product2>([SELECT Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :product2Ids]);
        for(OrderItem item :orderItems) {
            if(productMap.containsKey(item.Product2Id)) {
                productMap.get(item.product2Id).Quantity_Ordered__c -= item.Quantity;
            }
        }
        update productMap.values();
    }

}
Hi Gang,

Been trying all sorts of things to figure out anymore details for this error message that appears when I check the challenge on step 7, but coming up short.  Has anyone else experienced this error and any tips to resolve?

Challenge Not yet complete... here's what's wrong:
Ensure that the page works for existing Order records.

I have overridden both the New and Edit buttons/actions on the Order object.  My OrderExtension class appears to be working correctly in that I can successfully add new orders and edit them using the OrderEdit override vf page.  (The instructions specifically say not to edit that vf page so I have left it as is).  

In the log I see this is where it fails the check:
FATAL_ERROR AnonymousBlock: line 18, column 1
But unfortunately there are no real additional details that I see.

Any advice to resolve this or any tip to see more error information would be appreciated. 

Thanks!
Hi,

I'm currently struggling with Lightning Component Framework Specialist Challenge 10.

The map is behaving as expected, but when I submit, I get the error:
Challenge Not yet complete... here's what's wrong: 
MapController.js must have an event handler named onPlotMapMarker that uses the latitude and longitude that were passed through the event to update the boat’s location.

This is my onPlotMarker() method:
onPlotMapMarker: function(component, event, helper) {
    	var id = event.getParam('sObjectId');
    	var latitude = event.getParam('lat');
    	var longitude = event.getParam('long');
    	var label = event.getParam('label');

		var leafletMap = helper.getLeafletMap(component, latitude, longitude);
		L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
		    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
		}).addTo(leafletMap);
		
		L.marker([latitude, longitude]).addTo(leafletMap)
		    .bindPopup(label)
		    .openPopup();
    }
This is the helper:
({
	getLeafletMap : function(component, latitude, longitude) {
		var leafletMap = component.get('v.leafletMap');
		
		if (!leafletMap) {
	    	var mapContainer = component.find('map').getElement(); 
		    leafletMap = L.map(mapContainer, {zoomControl: false, tap: false})
		    	.setView([latitude, longitude], 13);
		    component.set('v.leafletMap', leafletMap);
		}

		return leafletMap;
	}
})
This is the aura:attribute for leafletMap:
<aura:attribute access="private" name="leafletMap" type="Object" />

Any help will be appreciated!






 
I have built the reports and dashboards as outlined in the requirements, but I'm getting the following error "Challenge Not yet complete... here's what's wrong: Couldn't find a component with the title 'My Top Accounts'."  
User-added image

However, I have the component on the dashboard as you can see below.
User-added image
What am I missing?
I'm unable to check step 2: Automate Accounts because I'm receiving this error: 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: ZKCVFIZH