• Yogesh D
  • NEWBIE
  • 70 Points
  • Member since 2015
  • Software Engineer
  • Insidesales.com


  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 14
    Replies
Performing the first Challenge of this Superbadge for APEX, I am receiving the below error. But it is not true because the Maintenance Request does indeed have all of the attributes cited when I try via the GUI and via a Test Class. Can someone please tell me what is wrong?

Challenge Not yet complete... here's what's wrong:
Inserting a new Maintenance Request of type 'Routine Maintenance' and then closing it did not create of a new Maintenance Request based upon the original record correctly. The challenge is expecting to find the closed Maintenance Request plus an 'New' Maintenance Request of type 'Routine Maintenance' with the same Vehicle as the closed one.

(Also, the challenge didn't specifically mention that the Case and Product2 objects should be relabeled)
I wanted to redo few of the badges that I had completed last year just for a revision purpose. I also wanted to take up the challenges that I have already completed. Is there any way to do this ?
Hello,

For this superbadge in the given entity relation diagram there is no connection that depicts the direct relation between Maintenance Request (case) and Equipment (Product). It is very confusing looking at the diagram given to understand this. Earlier in my solution to challenge 1 I assumed that there is no direct relation between the said objects and that I need to access the Equipment data by traversing the junction object (Work Part). Solution became much simpler when I swa that there is already a direct relation between Maintenance Request (case) and Equipment (Product).
Please look into this. Correct me I am wrong. Thank you.

 User-added image
Do we have to add 'Repair' and 'Routine Maintenance' values to the existing Type picklist values on Case object ?
I have already completed Cloak of Adventure challenge and also received a confirmation email about it. I read in one of the discussion that it approximately takes 2-3 weeks to deliver the sweatshirt to your address. But, in my case I had received the confirmation email almost a month back and still haven't received the sweatshirt yet. Is there anything else that I need to do, to receive it? (I don't know if this is the right platform to ask this kind of question, so please ignore if irrelevant).
Hello,

For this superbadge in the given entity relation diagram there is no connection that depicts the direct relation between Maintenance Request (case) and Equipment (Product). It is very confusing looking at the diagram given to understand this. Earlier in my solution to challenge 1 I assumed that there is no direct relation between the said objects and that I need to access the Equipment data by traversing the junction object (Work Part). Solution became much simpler when I swa that there is already a direct relation between Maintenance Request (case) and Equipment (Product).
Please look into this. Correct me I am wrong. Thank you.

 User-added image
I wanted to redo few of the badges that I had completed last year just for a revision purpose. I also wanted to take up the challenges that I have already completed. Is there any way to do this ?
Performing the first Challenge of this Superbadge for APEX, I am receiving the below error. But it is not true because the Maintenance Request does indeed have all of the attributes cited when I try via the GUI and via a Test Class. Can someone please tell me what is wrong?

Challenge Not yet complete... here's what's wrong:
Inserting a new Maintenance Request of type 'Routine Maintenance' and then closing it did not create of a new Maintenance Request based upon the original record correctly. The challenge is expecting to find the closed Maintenance Request plus an 'New' Maintenance Request of type 'Routine Maintenance' with the same Vehicle as the closed one.

(Also, the challenge didn't specifically mention that the Case and Product2 objects should be relabeled)
The trigger is failing tests this is the main fail reason. (The Field that's failing is a forumla field)
System.DmlException: Update failed. First exception on row 0 with id 0063300000j4vZzAAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppLineSyncTrigger: execution of AfterInsert

caused by: System.SObjectException: Field Product_Type_quote_sync__c is not editable

Trigger.OppLineSyncTrigger: line 128, column 1: []

Here is the Trigger itself:

trigger OppLineSyncTrigger on OpportunityLineItem (before insert, after insert, after update) {
    
    if (trigger.isBefore && trigger.isInsert) {
        if (QuoteSyncUtil.isRunningTest) {
            for (OpportunityLineItem oli : trigger.new) {
                QuoteSyncUtil.populateRequiredFields(oli);
            }
        }    
        return;
    }
    
    if (TriggerStopper.stopOppLine) return;
       
    Set<String> quoteLineFields = QuoteSyncUtil.getQuoteLineFields();
    List<String> oppLineFields = QuoteSyncUtil.getOppLineFields();
    
    String qliFields = QuoteSyncUtil.getQuoteLineFieldsString();
    
    String oliFields =  QuoteSyncUtil.getOppLineFieldsString();
    
    String oliIds = '';
    for (OpportunityLineItem oli : trigger.new) {
        if (oliIds != '') oliIds += ', ';
        oliIds += '\'' + oli.Id + '\'';
    }

    String oliQuery = 'select Id, OpportunityId, PricebookEntryId, UnitPrice, Quantity, Discount, ServiceDate, SortOrder' + oliFields + ' from OpportunityLineItem where Id in (' + oliIds + ')';
    //System.debug(oliQuery); 
     
    List<OpportunityLineItem> olis = Database.query(oliQuery);
    
    Map<Id, List<OpportunityLineItem>> oppToOliMap = new Map<Id, List<OpportunityLineItem>>();    
    
    for (OpportunityLineItem oli : olis) {
        List<OpportunityLineItem> oliList = oppToOliMap.get(oli.OpportunityId);
        if (oliList == null) {
            oliList = new List<OpportunityLineItem>();
        } 
        oliList.add(oli);  
        oppToOliMap.put(oli.OpportunityId, oliList);       
    }

    Set<Id> oppIds = oppToOliMap.keySet();
    Map<Id, Opportunity> opps = new Map<Id, Opportunity>([select id, SyncedQuoteId from Opportunity where Id in :oppIds and SyncedQuoteId != null]);
    
    String quoteIds = '';
    for (Opportunity opp : opps.values()) {
        if (opp.SyncedQuoteId != null) {
           if (quoteIds != '') quoteIds += ', ';
           quoteIds += '\'' + opp.SyncedQuoteId + '\'';         
        }
    }
   
    if (quoteIds != '') {
           
        String qliQuery = 'select Id, QuoteId, PricebookEntryId, UnitPrice, Quantity, Discount, ServiceDate, SortOrder' + qliFields + ' from QuoteLineItem where QuoteId in (' + quoteIds + ')';   
        //System.debug(qliQuery);    
               
        List<QuoteLineItem> qlis = Database.query(qliQuery);
        
        Map<Id, List<QuoteLineItem>> quoteToQliMap = new Map<Id, List<QuoteLineItem>>();
        
        for (QuoteLineItem qli : qlis) {
            List<QuoteLineItem> qliList = quoteToQliMap.get(qli.QuoteId);
            if (qliList == null) {
                qliList = new List<QuoteLineItem>();
            } 
            qliList.add(qli);  
            quoteToQliMap.put(qli.QuoteId, qliList);       
        }
             
        Set<QuoteLineItem> updateQlis = new Set<QuoteLineItem>();
        Set<OpportunityLineItem> updateOlis = new Set<OpportunityLineItem>();
                        
        for (Opportunity opp : opps.values()) {  
        
            List<QuoteLineItem> quotelines = quoteToQliMap.get(opp.SyncedQuoteId);  
            
            // for opp line insert, there will not be corresponding quote line
            if (quotelines == null) continue;      
        
            Set<QuoteLineItem> matchedQlis = new Set<QuoteLineItem>();        
        
            for (OpportunityLineItem oli : oppToOliMap.get(opp.Id)) {
 
                boolean updateQli = false;
                OpportunityLineItem oldOli = null;
                
                if (trigger.isUpdate) {
                    //System.debug('Old oli: ' + oldOli.UnitPrice + ', ' + oldOli.Quantity + ', ' + oldOli.Discount + ', ' + oldOli.ServiceDate);
                    //System.debug('New oli: ' + oli.UnitPrice + ', ' + oli.Quantity + ', ' + oli.Discount + ', ' + oli.ServiceDate);
                                 
                    oldOli = trigger.oldMap.get(oli.Id);
                    if (oli.UnitPrice == oldOli.UnitPrice
                        && oli.Quantity == oldOli.Quantity
                        && oli.Discount == oldOli.Discount
                        && oli.ServiceDate == oldOli.ServiceDate
                        && oli.SortOrder == oldOli.SortOrder 
                       )
                        updateQli = true;  
                }
                                                   
                boolean hasChange = false;
                boolean match = false;
                                  
                for (QuoteLineItem qli : quotelines) {       
                    if (oli.pricebookentryid == qli.pricebookentryId 
                        && oli.UnitPrice == qli.UnitPrice 
                        && oli.Quantity == qli.Quantity 
                        && oli.Discount == qli.Discount
                        && oli.ServiceDate == qli.ServiceDate
                        && oli.SortOrder == qli.SortOrder
                       ) {
                       
                        if (updateQlis.contains(qli) || matchedQlis.contains(qli)) continue;
                        
                        matchedQlis.add(qli);                                                    
                                                                               
                        for (String qliField : quoteLineFields) {
                            String oliField = QuoteSyncUtil.getQuoteLineFieldMapTo(qliField);
                            Object oliValue = oli.get(oliField);                          
                            Object qliValue = qli.get(qliField);
                             
                            if (oliValue != qliValue) { 
                                                        
                                if (trigger.isInsert) {
                                    if (qliValue == null) oli.put(oliField, null);
                                   
 else oli.put(oliField, qliValue);
                                    hasChange = true;

                                } else if (trigger.isUpdate && !updateQli /*&& oldOli != null*/) {
                                    //Object oldOliValue = oldOli.get(oliField); 
                                    //if (oliValue == oldOliValue) {                                    
                                        if (qliValue == null) oli.put(oliField, null);
                                        else oli.put(oliField, qliValue);
                                        hasChange = true;
                                    //}    
                                                                        
                                } else if (trigger.isUpdate && updateQli) {
                                    if (oliValue == null) qli.put(qliField, null);
                                    else qli.put(qliField,  oliValue);
                                    hasChange = true;
                                }
                            }
                        }
                        if (hasChange) {
                            if (trigger.isInsert || (trigger.isUpdate && !updateQli)) { 
                                updateOlis.add(oli);
                            } else if (trigger.isUpdate && updateQli) { 
                                updateQlis.add(qli);
                            }                    
                        }
                        
                        match = true;                       
                        break;                
                    } 
                }
                                                                
                // NOTE: this cause error when there is workflow field update that fired during record create
                //if (trigger.isUpdate && updateQli) System.assert(match, 'No matching quoteline');     
            }
        }

        TriggerStopper.stopOpp = true;
        TriggerStopper.stopQuote = true;        
        TriggerStopper.stopOppLine = true;        
        TriggerStopper.stopQuoteLine = true;    
                    
        if (!updateOlis.isEmpty()) {  
            List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
            oliList.addAll(updateOlis);
                           
            Database.update(oliList);              
        }
        
        if (!updateQlis.isEmpty()) { 
            List<QuoteLineItem> qliList = new List<QuoteLineItem>();   
            qliList.addAll(updateQlis);
                          
            Database.update(qliList);            
        }                             
        
        TriggerStopper.stopOpp = false;
        TriggerStopper.stopQuote = false;         
        TriggerStopper.stopOppLine = false;          
        TriggerStopper.stopQuoteLine = false; 
    }
}

The line i've put ma strikethrough is the one causing the fail, any help would be very much appreciated.

Regards

Richard
Hello,

For this superbadge in the given entity relation diagram there is no connection that depicts the direct relation between Maintenance Request (case) and Equipment (Product). It is very confusing looking at the diagram given to understand this. Earlier in my solution to challenge 1 I assumed that there is no direct relation between the said objects and that I need to access the Equipment data by traversing the junction object (Work Part). Solution became much simpler when I swa that there is already a direct relation between Maintenance Request (case) and Equipment (Product).
Please look into this. Correct me I am wrong. Thank you.

 User-added image
Do we have to add 'Repair' and 'Routine Maintenance' values to the existing Type picklist values on Case object ?
How to check Cloak of Adventure sweatshirt is available for my account.

I have completed the challeges and got 6 badges.Compass of Wisdom badge is showing in my profile.

But where to check Cloak of Adventure sweatshirt available or not for my profile .

Thanks 
Rathina