• NewGirl
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 17
    Replies

Is there a way to sort (order by) the grand total column in a matrix report??

If so, how??

 

Thanks for your help!

Karen

I run my test case (see below) and it only covers it 60%.  when I read the detailed output it doesn't look like the trigger is working?  thanks for your help!  After the test case I listed the debug log....

 

Also why do my System.assertEquals statement return : System.assertEquals(ANY, ANY) - instead of the value???

 

Thanks for your help!

Karen

 

@isTest
private class ConvertOppLIQtyTest{
    static testMethod void testOppLIQty(){
    
 
    
    //Setup the Account record
    Account a = new Account(Name = 'Test Account');
    a.Type = 'Customer';
    insert a;
    
    // Verify that the initial state is as expected
    a = [SELECT Name, Type
        FROM Account
        Where Id = :a.Id];
    System.assertEquals ('Customer', a.Type);
    
    // setup the Opportunity record
    
    String opportunityName = 'Test Opportunity';
    Opportunity o = new Opportunity(AccountId=a.Id, name=opportunityName, StageName='4 - Closed Won', CloseDate = Date.today(),PO_Number__c='999', Order_ID__c='999', opp_ship_to__c='017' );
                                    
    
    insert o;
    
    opportunity opp = [select name from opportunity where Id = :o.Id];
     System.assertEquals (opportunityname, opp.name);

//     ----------------------------------------

     // set up product2 and Verify that the results are as expected.
        Product2 p2 = new Product2(Name='AMS300',isActive=true);
        insert p2;
        Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id];
        System.assertEquals('AMS300', p2ex.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2.Id, UnitPrice=99, isActive=true);
        insert pbe;
        PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id ];
 //       System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
 
 //------------------------
        
            // set up product2 and Verify that the results are as expected.
        Product2 p2a = new Product2(Name='AMS305-10PK',isActive=true);
        insert p2a;
        Product2 p2exa = [SELECT Name FROM Product2 WHERE Id = :p2a.Id];
        System.assertEquals('AMS305-10PK', p2exa.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbea = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2a.Id, UnitPrice=99, isActive=true);
        insert pbea;
        PricebookEntry pbeexa = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id ];
//        System.assertEquals(standardPriceBookId, pbeexa.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem olia = new OpportunityLineItem(PriceBookEntryId=pbea.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
           
    Test.startTest();
          insert oli;
          insert olia;
    Test.stopTest();


    
 
    }
}

 

---------------------------------DEBUG LOG----------------------------------------------------------------

21.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
09:52:36.086|EXECUTION_STARTED
09:52:36.086|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000001FRX|ConvertOppLIQtyTest.testOppLIQty
09:52:36.086|METHOD_ENTRY|[2]|01pQ00000001FRX|ConvertOppLIQtyTest.ConvertOppLIQtyTest()
09:52:36.086|METHOD_EXIT|[2]|ConvertOppLIQtyTest
09:52:36.086|DML_BEGIN|[10]|Op:Insert|Type:Account|Rows:1
09:52:36.213|DML_END|[10]
09:52:36.213|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|SELECT Name, Type
FROM Account
Where Id = :a.Id
09:52:36.219|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.219|METHOD_ENTRY|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_EXIT|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_ENTRY|[21]|Date.today()
09:52:36.220|METHOD_EXIT|[21]|Date.today()
09:52:36.220|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
09:52:36.356|DML_END|[24]
09:52:36.356|SOQL_EXECUTE_BEGIN|[26]|Aggregations:0|select name from opportunity where Id = :o.Id
09:52:36.361|SOQL_EXECUTE_END|[26]|Rows:1
09:52:36.361|METHOD_ENTRY|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|METHOD_EXIT|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|DML_BEGIN|[33]|Op:Insert|Type:Product2|Rows:1
09:52:36.419|DML_END|[33]
09:52:36.419|SOQL_EXECUTE_BEGIN|[34]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2.Id
09:52:36.424|SOQL_EXECUTE_END|[34]|Rows:1
09:52:36.424|METHOD_ENTRY|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|METHOD_EXIT|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|DML_BEGIN|[39]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.476|DML_END|[39]
09:52:36.476|SOQL_EXECUTE_BEGIN|[40]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id 
09:52:36.479|SOQL_EXECUTE_END|[40]|Rows:1
09:52:36.480|DML_BEGIN|[51]|Op:Insert|Type:Product2|Rows:1
09:52:36.492|DML_END|[51]
09:52:36.492|SOQL_EXECUTE_BEGIN|[52]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2a.Id
09:52:36.496|SOQL_EXECUTE_END|[52]|Rows:1
09:52:36.496|METHOD_ENTRY|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|METHOD_EXIT|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|DML_BEGIN|[57]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.504|DML_END|[57]
09:52:36.504|SOQL_EXECUTE_BEGIN|[58]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id 
09:52:36.507|SOQL_EXECUTE_END|[58]|Rows:1
09:52:36.507|METHOD_ENTRY|[1]|Test.Test()
09:52:36.507|METHOD_EXIT|[1]|Test
09:52:36.507|METHOD_ENTRY|[65]|system.Test.startTest()
09:52:36.508|METHOD_EXIT|[65]|system.Test.startTest()
09:52:36.508|DML_BEGIN|[66]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.516|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.516|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.516|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.516|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[11]|DEBUG|01uQ0000004gObvIAE
09:52:36.516|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.516|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.519|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.519|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.522|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.522|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.522|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.522|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.523|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.523|USER_DEBUG|[31]|DEBUG|77
09:52:36.523|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.817|CUMULATIVE_LIMIT_USAGE
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TESTING_LIMITS
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 8 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.817|CUMULATIVE_LIMIT_USAGE_END

09:52:36.523|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.605|DML_END|[66]
09:52:36.605|DML_BEGIN|[67]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.610|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.610|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.610|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.610|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.611|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.611|USER_DEBUG|[11]|DEBUG|01uQ0000004gObwIAE
09:52:36.611|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.611|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.613|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.613|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.618|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.618|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.618|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.618|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[31]|DEBUG|77
09:52:36.618|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.912|CUMULATIVE_LIMIT_USAGE
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TESTING_LIMITS
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 17 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.912|CUMULATIVE_LIMIT_USAGE_END

09:52:36.619|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.665|DML_END|[67]
09:52:36.665|METHOD_ENTRY|[68]|system.Test.stopTest()
09:52:36.665|METHOD_EXIT|[68]|system.Test.stopTest()
09:52:36.959|CUMULATIVE_LIMIT_USAGE
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TESTING_LIMITS
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 18 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.959|CUMULATIVE_LIMIT_USAGE_END

09:52:36.665|CODE_UNIT_FINISHED|ConvertOppLIQtyTest.testOppLIQty
09:52:36.665|EXECUTION_FINISHED
09:52:38.311|CUMULATIVE_PROFILING_BEGIN
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOQL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOSL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for DML operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for method invocations
09:52:38.311|CUMULATIVE_PROFILING_END

I have written a trigger to update the amount and quantity on the opportunitylineitems table.

It works fine if I am insertingonly one product to the opportunitylineitem.  However, if I am writting 2 or more products (line items) it runs through tthe trigger multiple times and I end up with incorrect data.

 

Any help would be appreciated!!

thanks,

Karen

 

 

 

 

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

Set<Id> OrderLineIds= new Set<Id>();                
Set<Id> LineItemIds= new Set<Id>();
    
Set<String> PBEIdSet = new Set<String>();
Set<String> Prod2IdSet = new Set<String>();
       
    for (OpportunityLineItem insertedlineitem : system.Trigger.new)   
    {   

System.debug('INSIDE OPP FOR LOOP!!!'); 

        if (insertedlineitem.PricebookEntryId  != null) {
System.debug(insertedlineitem.PricebookEntryId );
            PBEIdSet.add(insertedlineitem.PricebookEntryId );
        }
        List<PricebookEntry> ParentPricebookEntry = [SELECT Product2Id           
                                            from PricebookEntry                            
                                            where id in :PBEIdSet];
        for(PricebookEntry pbes: ParentPricebookEntry) {            
            if (pbes.Product2Id != null) {
                System.debug('PROD ID ' + pbes.Product2Id);
                Prod2IdSet.add(pbes.Product2Id);   
            }
            List<Product2> ParentProd = [SELECT ProductCode
                                                   from Product2
                                                   where id in :Prod2IdSet];                                            
            for(Product2 prods: ParentProd) {
                System.debug('PROD CODE ' + prods.ProductCode);
                if(prods.ProductCode == 'AMS300' || prods.ProductCode == 'AMS305' || prods.ProductCode == 'AMS310-5PK' || prods.ProductCode == 'AMS350-5PK' || prods.ProductCode == 'AMS505' || prods.ProductCode == 'MDS405') {
                   System.debug('BEFORE QTY ' + insertedlineitem.quantity);
                   insertedlineitem.quantity = insertedlineitem.quantity * 5;
                   insertedlineitem.unitprice = insertedlineitem.unitprice / 5;
                    System.debug('AFTER QTY ' + insertedlineitem.quantity);
                                    
                }
         
                if(prods.ProductCode == 'AMS300-10PK' || prods.ProductCode == 'AMS305-10PK' || prods.ProductCode == 'AMS600' || prods.ProductCode == 'AMS604' || prods.ProductCode == 'AMS607' || prods.ProductCode == 'AMS612'|| prods.ProductCode == 'AMS700') {
                   insertedlineitem.quantity = insertedlineitem.quantity * 10;
                   insertedlineitem.unitprice = insertedlineitem.unitprice / 10;
            }
System.debug('77'); 
        }
        }
        system.debug('END OF OPPLINEITEM LOOP');
        }
        system.debug('end!!!!!');
        }

 

I am trying to update opportunitylineitem quantity when the productcode equals a certain value.
I wrote the below trigger as a first pass before I put in more detailed code.  
I am receiving a compile error :
Compile Error: Invalid field productid for SObject OpportunityLineItem at line 10 column 86
I highlighted the field that is in question in red.
thanks for ANY help!!!!
trigger convertproductqty on OpportunityLineItem (before insert, before update) {
     
 // string ProdCode;
 
 Opportunitylineitem[] OppLI = Trigger.new; 
    
 for(OpportunityLineItem s:OppLI){
     if (s.productid != null)
       {
       string prodcode = [select productcode from pricebookentry where product2id = :s.productid].productid;
       if (prodcode == 'AMS300')
           {
           s.quantity = 999;
           }
       }
    }
 }

 

I have two systems one is an ERP system...that will allow me to get the data out in a CSV or excel file, the other is Salesforce.  I have about 5000 accounts in each of them.  I need to update salesforce accounts (a custom field) with the organization id from the ERP system.

 

Does anyone know an easy way to do this?  How will I match the 2 up...based on account name and address.  

Its difficult to compare S. Main St. with South Main Street.

 

Is there a tool that could at least help update all the exact matches?  I imagine it wouldn't reconcile all 5000 records but maybe a few thousand.

 

Please advise!

 

 

When I  say "user id," I mean literally the ID, the primary key of the user record, like 00530000000elgt?

 

Thanks for your help!

Karen

 

I have a custom field called Really_Big_Deal__c that is a data type "checkbox".  
I need to evaluate it in an apex trigger.  I know checkbox is a boolean - what do I need to do to evaluate this?
The code is as follows...
trigger OrderOwnerUpdate on Opportunity (before insert, before update) {
//change the owner from customer service to RSM
ID TerritoryId;
Opportunity[] opp = Trigger.new;
for (opportunity s:opp)
  {
    if (s.name != null)
        {
            ID OpportunityOwnerId = [Select User_id__c from territories__c 
            where name = :s.opp_ship_to__c].user_id__c;
            s.ownerid = OpportunityOwnerId;
            
            if ((s.amount >9899) && (s.Really_Big_Deal__c == true ))
            {
                s.addError('Check Big Deal Field if sale is over $9899.00');
            }
        }
  }
}
Thanks for any insight to this issue!
Karen

 

I have created a field validation - but once the error is displayed I want to continue...

 

Is this possible?

 

Thanks for your help!

Hello All - 

 

I am new to SF and I just wrote my first apex trigger.  I believe that in order to deploy the trigger into production I need to write test cases?  How and where do I do this?  I have looked at samples but they seem complex?

 

Any help would be great!

 

Below is my trigger....

Thanks!!!

 

 

 

trigger OrderOwnerUpdate on Opportunity (before insert, before update) {
//change the owner from customer service to RSM
ID TerritoryId;

Opportunity[] opp = Trigger.new;
for (opportunity s:opp)
  {
    if (s.name != null)
        {
            ID OpportunityOwnerId = [Select User_id__c from territories__c 
            where name = :s.opp_ship_to__c].user_id__c;
            s.ownerid = OpportunityOwnerId;
        }
  }

}

How can I do look up field on the opportunity product table? 

I have a custom object (table) and I need to do a related list with the opportunity product table.

 

Thanks for your help!

Hello All -

 

I need to scan a barcode into a salesforce screen.  How do I then break up the barcode string into different salesforce fields?

 

Thanks for you help!

 

I have created a custom tab as well as some custom reports. 

I was hoping there was a way to display the folder of custom reports from the custom tab.  That way Regional Sales Managers who have access can run their reports off of the custom tab.

 

Thanks in advance for your help!!!

Does either Sforce Explorer or Force.com Explorer support the length function?

I can't seem to get it to work?

 

I run my test case (see below) and it only covers it 60%.  when I read the detailed output it doesn't look like the trigger is working?  thanks for your help!  After the test case I listed the debug log....

 

Also why do my System.assertEquals statement return : System.assertEquals(ANY, ANY) - instead of the value???

 

Thanks for your help!

Karen

 

@isTest
private class ConvertOppLIQtyTest{
    static testMethod void testOppLIQty(){
    
 
    
    //Setup the Account record
    Account a = new Account(Name = 'Test Account');
    a.Type = 'Customer';
    insert a;
    
    // Verify that the initial state is as expected
    a = [SELECT Name, Type
        FROM Account
        Where Id = :a.Id];
    System.assertEquals ('Customer', a.Type);
    
    // setup the Opportunity record
    
    String opportunityName = 'Test Opportunity';
    Opportunity o = new Opportunity(AccountId=a.Id, name=opportunityName, StageName='4 - Closed Won', CloseDate = Date.today(),PO_Number__c='999', Order_ID__c='999', opp_ship_to__c='017' );
                                    
    
    insert o;
    
    opportunity opp = [select name from opportunity where Id = :o.Id];
     System.assertEquals (opportunityname, opp.name);

//     ----------------------------------------

     // set up product2 and Verify that the results are as expected.
        Product2 p2 = new Product2(Name='AMS300',isActive=true);
        insert p2;
        Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id];
        System.assertEquals('AMS300', p2ex.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2.Id, UnitPrice=99, isActive=true);
        insert pbe;
        PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id ];
 //       System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
 
 //------------------------
        
            // set up product2 and Verify that the results are as expected.
        Product2 p2a = new Product2(Name='AMS305-10PK',isActive=true);
        insert p2a;
        Product2 p2exa = [SELECT Name FROM Product2 WHERE Id = :p2a.Id];
        System.assertEquals('AMS305-10PK', p2exa.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbea = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2a.Id, UnitPrice=99, isActive=true);
        insert pbea;
        PricebookEntry pbeexa = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id ];
//        System.assertEquals(standardPriceBookId, pbeexa.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem olia = new OpportunityLineItem(PriceBookEntryId=pbea.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
           
    Test.startTest();
          insert oli;
          insert olia;
    Test.stopTest();


    
 
    }
}

 

---------------------------------DEBUG LOG----------------------------------------------------------------

21.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
09:52:36.086|EXECUTION_STARTED
09:52:36.086|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000001FRX|ConvertOppLIQtyTest.testOppLIQty
09:52:36.086|METHOD_ENTRY|[2]|01pQ00000001FRX|ConvertOppLIQtyTest.ConvertOppLIQtyTest()
09:52:36.086|METHOD_EXIT|[2]|ConvertOppLIQtyTest
09:52:36.086|DML_BEGIN|[10]|Op:Insert|Type:Account|Rows:1
09:52:36.213|DML_END|[10]
09:52:36.213|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|SELECT Name, Type
FROM Account
Where Id = :a.Id
09:52:36.219|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.219|METHOD_ENTRY|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_EXIT|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_ENTRY|[21]|Date.today()
09:52:36.220|METHOD_EXIT|[21]|Date.today()
09:52:36.220|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
09:52:36.356|DML_END|[24]
09:52:36.356|SOQL_EXECUTE_BEGIN|[26]|Aggregations:0|select name from opportunity where Id = :o.Id
09:52:36.361|SOQL_EXECUTE_END|[26]|Rows:1
09:52:36.361|METHOD_ENTRY|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|METHOD_EXIT|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|DML_BEGIN|[33]|Op:Insert|Type:Product2|Rows:1
09:52:36.419|DML_END|[33]
09:52:36.419|SOQL_EXECUTE_BEGIN|[34]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2.Id
09:52:36.424|SOQL_EXECUTE_END|[34]|Rows:1
09:52:36.424|METHOD_ENTRY|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|METHOD_EXIT|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|DML_BEGIN|[39]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.476|DML_END|[39]
09:52:36.476|SOQL_EXECUTE_BEGIN|[40]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id 
09:52:36.479|SOQL_EXECUTE_END|[40]|Rows:1
09:52:36.480|DML_BEGIN|[51]|Op:Insert|Type:Product2|Rows:1
09:52:36.492|DML_END|[51]
09:52:36.492|SOQL_EXECUTE_BEGIN|[52]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2a.Id
09:52:36.496|SOQL_EXECUTE_END|[52]|Rows:1
09:52:36.496|METHOD_ENTRY|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|METHOD_EXIT|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|DML_BEGIN|[57]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.504|DML_END|[57]
09:52:36.504|SOQL_EXECUTE_BEGIN|[58]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id 
09:52:36.507|SOQL_EXECUTE_END|[58]|Rows:1
09:52:36.507|METHOD_ENTRY|[1]|Test.Test()
09:52:36.507|METHOD_EXIT|[1]|Test
09:52:36.507|METHOD_ENTRY|[65]|system.Test.startTest()
09:52:36.508|METHOD_EXIT|[65]|system.Test.startTest()
09:52:36.508|DML_BEGIN|[66]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.516|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.516|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.516|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.516|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[11]|DEBUG|01uQ0000004gObvIAE
09:52:36.516|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.516|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.519|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.519|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.522|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.522|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.522|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.522|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.523|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.523|USER_DEBUG|[31]|DEBUG|77
09:52:36.523|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.817|CUMULATIVE_LIMIT_USAGE
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TESTING_LIMITS
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 8 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.817|CUMULATIVE_LIMIT_USAGE_END

09:52:36.523|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.605|DML_END|[66]
09:52:36.605|DML_BEGIN|[67]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.610|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.610|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.610|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.610|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.611|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.611|USER_DEBUG|[11]|DEBUG|01uQ0000004gObwIAE
09:52:36.611|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.611|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.613|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.613|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.618|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.618|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.618|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.618|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[31]|DEBUG|77
09:52:36.618|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.912|CUMULATIVE_LIMIT_USAGE
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TESTING_LIMITS
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 17 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.912|CUMULATIVE_LIMIT_USAGE_END

09:52:36.619|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.665|DML_END|[67]
09:52:36.665|METHOD_ENTRY|[68]|system.Test.stopTest()
09:52:36.665|METHOD_EXIT|[68]|system.Test.stopTest()
09:52:36.959|CUMULATIVE_LIMIT_USAGE
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TESTING_LIMITS
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 18 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.959|CUMULATIVE_LIMIT_USAGE_END

09:52:36.665|CODE_UNIT_FINISHED|ConvertOppLIQtyTest.testOppLIQty
09:52:36.665|EXECUTION_FINISHED
09:52:38.311|CUMULATIVE_PROFILING_BEGIN
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOQL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOSL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for DML operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for method invocations
09:52:38.311|CUMULATIVE_PROFILING_END

I have written a trigger to update the amount and quantity on the opportunitylineitems table.

It works fine if I am insertingonly one product to the opportunitylineitem.  However, if I am writting 2 or more products (line items) it runs through tthe trigger multiple times and I end up with incorrect data.

 

Any help would be appreciated!!

thanks,

Karen

 

 

 

 

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

Set<Id> OrderLineIds= new Set<Id>();                
Set<Id> LineItemIds= new Set<Id>();
    
Set<String> PBEIdSet = new Set<String>();
Set<String> Prod2IdSet = new Set<String>();
       
    for (OpportunityLineItem insertedlineitem : system.Trigger.new)   
    {   

System.debug('INSIDE OPP FOR LOOP!!!'); 

        if (insertedlineitem.PricebookEntryId  != null) {
System.debug(insertedlineitem.PricebookEntryId );
            PBEIdSet.add(insertedlineitem.PricebookEntryId );
        }
        List<PricebookEntry> ParentPricebookEntry = [SELECT Product2Id           
                                            from PricebookEntry                            
                                            where id in :PBEIdSet];
        for(PricebookEntry pbes: ParentPricebookEntry) {            
            if (pbes.Product2Id != null) {
                System.debug('PROD ID ' + pbes.Product2Id);
                Prod2IdSet.add(pbes.Product2Id);   
            }
            List<Product2> ParentProd = [SELECT ProductCode
                                                   from Product2
                                                   where id in :Prod2IdSet];                                            
            for(Product2 prods: ParentProd) {
                System.debug('PROD CODE ' + prods.ProductCode);
                if(prods.ProductCode == 'AMS300' || prods.ProductCode == 'AMS305' || prods.ProductCode == 'AMS310-5PK' || prods.ProductCode == 'AMS350-5PK' || prods.ProductCode == 'AMS505' || prods.ProductCode == 'MDS405') {
                   System.debug('BEFORE QTY ' + insertedlineitem.quantity);
                   insertedlineitem.quantity = insertedlineitem.quantity * 5;
                   insertedlineitem.unitprice = insertedlineitem.unitprice / 5;
                    System.debug('AFTER QTY ' + insertedlineitem.quantity);
                                    
                }
         
                if(prods.ProductCode == 'AMS300-10PK' || prods.ProductCode == 'AMS305-10PK' || prods.ProductCode == 'AMS600' || prods.ProductCode == 'AMS604' || prods.ProductCode == 'AMS607' || prods.ProductCode == 'AMS612'|| prods.ProductCode == 'AMS700') {
                   insertedlineitem.quantity = insertedlineitem.quantity * 10;
                   insertedlineitem.unitprice = insertedlineitem.unitprice / 10;
            }
System.debug('77'); 
        }
        }
        system.debug('END OF OPPLINEITEM LOOP');
        }
        system.debug('end!!!!!');
        }

I have two systems one is an ERP system...that will allow me to get the data out in a CSV or excel file, the other is Salesforce.  I have about 5000 accounts in each of them.  I need to update salesforce accounts (a custom field) with the organization id from the ERP system.

 

Does anyone know an easy way to do this?  How will I match the 2 up...based on account name and address.  

Its difficult to compare S. Main St. with South Main Street.

 

Is there a tool that could at least help update all the exact matches?  I imagine it wouldn't reconcile all 5000 records but maybe a few thousand.

 

Please advise!

 

 

When I  say "user id," I mean literally the ID, the primary key of the user record, like 00530000000elgt?

 

Thanks for your help!

Karen

 

I have a custom field called Really_Big_Deal__c that is a data type "checkbox".  
I need to evaluate it in an apex trigger.  I know checkbox is a boolean - what do I need to do to evaluate this?
The code is as follows...
trigger OrderOwnerUpdate on Opportunity (before insert, before update) {
//change the owner from customer service to RSM
ID TerritoryId;
Opportunity[] opp = Trigger.new;
for (opportunity s:opp)
  {
    if (s.name != null)
        {
            ID OpportunityOwnerId = [Select User_id__c from territories__c 
            where name = :s.opp_ship_to__c].user_id__c;
            s.ownerid = OpportunityOwnerId;
            
            if ((s.amount >9899) && (s.Really_Big_Deal__c == true ))
            {
                s.addError('Check Big Deal Field if sale is over $9899.00');
            }
        }
  }
}
Thanks for any insight to this issue!
Karen

 

I have created a field validation - but once the error is displayed I want to continue...

 

Is this possible?

 

Thanks for your help!

Hello All - 

 

I am new to SF and I just wrote my first apex trigger.  I believe that in order to deploy the trigger into production I need to write test cases?  How and where do I do this?  I have looked at samples but they seem complex?

 

Any help would be great!

 

Below is my trigger....

Thanks!!!

 

 

 

trigger OrderOwnerUpdate on Opportunity (before insert, before update) {
//change the owner from customer service to RSM
ID TerritoryId;

Opportunity[] opp = Trigger.new;
for (opportunity s:opp)
  {
    if (s.name != null)
        {
            ID OpportunityOwnerId = [Select User_id__c from territories__c 
            where name = :s.opp_ship_to__c].user_id__c;
            s.ownerid = OpportunityOwnerId;
        }
  }

}

How can I do look up field on the opportunity product table? 

I have a custom object (table) and I need to do a related list with the opportunity product table.

 

Thanks for your help!

Hello All -

 

I need to scan a barcode into a salesforce screen.  How do I then break up the barcode string into different salesforce fields?

 

Thanks for you help!

 

I have created a custom tab as well as some custom reports. 

I was hoping there was a way to display the folder of custom reports from the custom tab.  That way Regional Sales Managers who have access can run their reports off of the custom tab.

 

Thanks in advance for your help!!!

Does either Sforce Explorer or Force.com Explorer support the length function?

I can't seem to get it to work?