• Mitch McConnell
  • NEWBIE
  • 60 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 12
    Replies

I am reviewing some code that I inherited  :-)

It uses a "before" trigger as follows.  It is trying to take a variable from the Quote and
copy it to the OpportunityLineItem.

trigger OpportunityProductTrigger on OpportunityLineItem (before insert, before update) {

    if(Trigger.isBefore){
        OpportunityProductServices.addParentSortOrderNumber(trigger.new);
    }
    
}



The method being called is as follows:
 
public class OpportunityProductServices{

    // Populating Base OpportunityLine Item's Sort Order number on Add-on OLI's 
    public static void addParentSortOrderNumber(List<OpportunityLineItem> lst_OLI){
    
        Set<String> set_OpportunityIds = new Set<String>(); // Creating Set of Opportunity Ids for which Opportunity Lineitem is created or updated
        for(OpportunityLineItem var : lst_OLI){
            set_OpportunityIds.add(var.OpportunityId);
        }
        
        Map<Id, Map<Id, QuoteLineItem>> map_Opprtunity2Quote = new Map<Id, Map<Id, QuoteLineItem>>();
        // Getting List of QLI for Opportunity ids which has Quote Quote Synced
        for(QuoteLineItem var : [Select Id, SortOrder, Base_OLI_Id__c, Quote.OpportunityId 
                                from QuoteLineItem WHERE Quote.isSyncing=true and 
                                Quote.OpportunityId IN : set_OpportunityIds]){
            if(map_Opprtunity2Quote.containsKey(var.Quote.OpportunityId)){
                map_Opprtunity2Quote.get(var.Quote.OpportunityId).put(var.Id, var);
            }else{
                Map<Id, QuoteLineItem> map_QuoteLine = new Map<Id, QuoteLineItem>();
                map_QuoteLine.put(var.Id, var);
                map_Opprtunity2Quote.put(var.Quote.OpportunityId, map_QuoteLine);
            }
        }
        for(OpportunityLineItem var : lst_OLI){
            Map<Id, QuoteLineItem> map_QuoteLine = map_Opprtunity2Quote.get(var.OpportunityId);
            for(QuoteLineItem QLI : map_QuoteLine.values()){
                // Putting Sort Number on Custom Field of OLI
                if(var.SortOrder == QLI.SortOrder && QLI.Base_OLI_Id__c != null){
                    var.Base_OLI_Sort_Number__c =  map_QuoteLine.get(QLI.Base_OLI_Id__c).sortOrder;  
                }
            }            
        }
    }

}


My question is this:

Since there are no DML operations being performed in the called method, does this
code *do* anything?

Is the "trigger.new" that is passed in directly from the trigger to the method passed by reference, and 
therefore setting Base_OLI_Sort_Number__c actually sets it somehow?

Thanks,

Mitch
 

I have a validation rule for Quote Line Items that says they cannot be edited if the Quote is synced..  If I edit one individually,
I get the error message at the top of the page, as expected.  But if I hit the "Edit All" button and make a change, the Save
button does not accept the change, i.e., it appears the rule is firing, but the error message does not display on the screen
anywhere.  I tried this in both Chome and IE, so it is not obviously a browser issue.  

Has anyone seen this before, and can you give me any advice?

Thanks,

Mitch

I am at my wit's end.  I am trying to increase our code coverage for a custom controller extension, and cannot seem to get it to work at all.   The controller class contains several internal classes that are used to manage its data representation.   What I mean is that although my test class clearly instantiates the controller (and passes), when I look at what that does, it shows the internal class as not being covered at all, even when by inspection you can see that it would be.

Also, the developer console (yes, I know it is awful, but that is the tool we have) doesn't update even when I add a line of code to the test that clearly executes a statement (in this case, just an assignment).

Has anyone else seen this type of behavior?  

I know there are many answers to the "too many" part of this question, and I understand the reason and the normally suggested solutions.  
But I believe I see this behavior change even running the same test on different occasions, i.e., with no code changes sometimes it will get this error, and sometimes not.

Does this seem possible?  Has anyone else experienced this?

And yes, I have (many times) tried most of the suggested solutions....  so this is more of a "is this really possible?" question.​
 

Hi EveryOne,
Are there any certain things where we will not be allowed to use @Future methods such as test classes,schedulable classes or some complex triggers and any situations that will not allow us to use @future method?  
I get how SVN can be used to share and merge files that developers in a team are working on.  But I would like to hear how people manage forced updates to a developer sandbox when some other change has been made to production.

For example, I have my Dev1 sandbox that I am working on, with many changes.

A 3rd party consulting company pushes a bunch of new features to production, some of which may impact my changes.

What do people do in this case?  In Eclipse, I can clearly have two projects, one that is my Dev1 and the other production.  How do they use Eclipse and SVN to manage merging these two code bases?



I am just starting to work on our SF implementation that already contains quite a bit of Apex code,

and I need to add some more.

I was getting errors on my test cases for my trigger, and I noticed that the existing

Opportunity Trigger tests, although they have 100% coverage, 50% of them fail!

Will SF allow code to be pushed as long as it meets the 75% metric, even though

the tests fail?

Thanks,

Mitch

I am running Eclipse Kepler with the Force.com IDE installed.  When I try and create a new SF project for a sandbox, it bypasses the "Choose Initial Project Components" screen, and all I can do is hit "Finish".  When this is done, it shows me *some* things, but not all of the classes and objects I need.  We are running Enterprise version 31.

I have done this before, but I think it was an older version of Eclipse. 

Can anyone explain why I am not getting to choose to load all components in my sandbox project?

Thanks,

Mitch
I am running the Force.com IDE in Eclipse (Kepler).

When I try and create a SOQL query, it is not resolving the relationships correctly.

For example, when I run this simple query:

      select Id, Account.Name from Opportunity

It returns rows like this

Id                                                      Name                                              Account
003i000000IugISAAZ                   Fred Roberts                                 Account
003i000000Iug04AAJ                  Bob Smith                                      Account

In other words, it does not show the Account name, but just the word "Account".

When I run this in the developer console, it is correct.

Is there some type of misconfiguration in my IDE setup?

Thanks,

Mitch