• InBlighty
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hi,

 

I'm thinking of adoptiong Salesforce to Salesforce and I'm wondering if I can just auto-forward all Lead records to a connection.  I don't see any option to do that and I think it would be very tedious to have someone have to hand-forward hundreds of leads a day. 

 

Maybe I'm missing the setting?  If there's no such , is there a way to do it using APEX?

 

Thanks!!

Hi,

 

I'm in a situation where my users are quite frustrated with the related list restriction of 10 columns imposed by Salesforce.  I'm looking for any Visualforce suggestions around accomplishing this.

 

In short, I've got a custom Order__c object and a master-detail Order_Line_Item__c object  which has about 15 very important fields, mostly numbers, that they would like to see (and perhaps edit) when viewing an Order.

 

I know I can just use <apex:dataTable> and put in the columns that way, but it doesn't look so great.  I would love to have a row in a dataTable actually break into two lines of fields, representing one row of data.

 

I'm open to any creative suggestions!

 

Thanks!! 

 

 

 

 

Hi,

 

I'm thinking of adoptiong Salesforce to Salesforce and I'm wondering if I can just auto-forward all Lead records to a connection.  I don't see any option to do that and I think it would be very tedious to have someone have to hand-forward hundreds of leads a day. 

 

Maybe I'm missing the setting?  If there's no such , is there a way to do it using APEX?

 

Thanks!!

Hi,

 

I'm in a situation where my users are quite frustrated with the related list restriction of 10 columns imposed by Salesforce.  I'm looking for any Visualforce suggestions around accomplishing this.

 

In short, I've got a custom Order__c object and a master-detail Order_Line_Item__c object  which has about 15 very important fields, mostly numbers, that they would like to see (and perhaps edit) when viewing an Order.

 

I know I can just use <apex:dataTable> and put in the columns that way, but it doesn't look so great.  I would love to have a row in a dataTable actually break into two lines of fields, representing one row of data.

 

I'm open to any creative suggestions!

 

Thanks!! 

 

 

 

 

I am learning to code APEX as I go and piecing together how to test and deploy as well. Through trial and error I was able to write a trigger that chooses the pricebook of an opportunity based upon what is selected in the drop down Lead Source:

 

trigger setPriceBook on Opportunity (before insert) {    
    ID PRICEBOOK_YOUCAN = '01s300000002kelAAA';    
    ID PRICEBOOK_QBPP = '01s300000002kZ2AAI';    
    ID PRICEBOOK_B2B = '01s300000002kZCAAY';    
    ID PRICEBOOK_DATAREF = '01s300000002kZ7AAI'; 
    ID PRICEBOOK_STANDARD = '01s300000006i5xAAA' ; 
    ID PRICEBOOK_WINBACK = '01s300000002kegAAA'  ;  
    String SOURCE_YOUCAN = 'YouCan';        
    String SOURCE_QBPP = 'QBPP';    
    String SOURCE_B2B = 'B2B';    
    String SOURCE_DATAREF = 'Data Referral';   
    String SOURCE_WINBACK = 'WinBack' ; 
    for( Opportunity oppty : trigger.new ) {                
        if ( oppty.LeadSource == SOURCE_YOUCAN ) {            
            oppty.Pricebook2Id = PRICEBOOK_YOUCAN;        
        }        
        else if ( oppty.LeadSource == SOURCE_QBPP ) {                       
            oppty.Pricebook2Id = PRICEBOOK_QBPP;        
        }        
        else if ( oppty.LeadSource == SOURCE_B2B ) {            
            oppty.Pricebook2ID = PRICEBOOK_B2B;        
        }        
        else if (oppty.LeadSource == SOURCE_DATAREF ) {            
            oppty.Pricebook2ID = PRICEBOOK_DATAREF;        
        } 
        else if (oppty.LeadSource == SOURCE_WINBACK ) {
            oppty.PriceBook2ID = PRICEBOOK_WINBACK;
        }
        else {
            oppty.Pricebook2ID = PRICEBOOK_STANDARD;
        }      
    }
}

 

Probably not the cleanest code ever...but it worked.

 

My problem is when I wrote my test class, which is even dirtier. It initially compiled and tested clean with 80% coverage. I thought I was ready to go until I realised that I had left out a variable in the trigger. When that got saved it took me to under 75% so I had to add more test cases in. I have no idea how I got so messed up, but as a result of all my trial and error, I can't even figure out what originally worked:

 

@isTEST
private class setPriceBookTest {
    static testMethod void testsetPriceBookYouCan () {
    //Create new YouCan Opportunity 
    Opportunity oppYouCan = new Opportunity ();
    oppYouCan.Description = 'TestYouCan';
    oppYouCan.LeadSource = 'YouCan';
    oppYouCan.StageName = 'New';
    oppYouCan.Name = 'YouCanTest2';
    oppYouCan.CloseDate = System.Today();
    insert oppYouCan;
    //Select the pricebook 
    Opportunity YouCanPriceBook = [SELECT Pricebook2ID
                                    FROM Opportunity
                                    WHERE Name = 'YouCanTest2'
                                    LIMIT 1];
    ID PriceBookYouCan = '01sQ00000008bamIAA';
    //Verify Price book
    System.assertNotEquals(null, YouCanPriceBook);
    //Create new QBPP Opportunity
    Opportunity oppQBPP = new Opportunity () ;
    oppQBPP.Description = 'TestQBPP';
    oppQBPP.LeadSource = 'QBPP';
    oppQBPP.StageName = 'New';
    oppQBPP.Name = 'QBPPTest2';
    oppQBPP.CloseDate = System.Today() ;
    Database.insert (oppQBPP);
    //Select the pricebook
    Opportunity QBPPPriceBook = [SELECT Pricebook2ID
                                    FROM Opportunity
                                    WHERE Name = 'QBPPTest2'
                                    LIMIT 1];
    ID PriceBookQBPP = '01sQ00000008bahIAA';
    //Verify Price book
    System.assertNotEquals (null, QBPPPriceBook);
    //Create new WinBack Opportunity
    Opportunity oppWinBack = new Opportunity () ;
    oppWinBack.Description = 'TestWinBack';
    oppWinBack.LeadSource = 'WinBack';
    oppWinBack.StageName = 'New';
    oppWinBack.Name = 'WimBackTest2';
    oppWinBack.CloseDate = System.Today() ;
    Database.insert (oppWinBack);
    //Select the pricebook
    Opportunity WinBackPriceBook = [SELECT Pricebook2ID
                                    FROM Opportunity
                                    WHERE Name = 'WinBackTest2'
                                    LIMIT 1];
    //Verify Price book
    System.assertNotEquals (null, WinBackPriceBook);

    }
 }

 

The error that I currently get when I run the test is:

 

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

 

I have read quite a few pages that make it sound like this is a permissions problem, however I believe I am running this test as a System Administrator who would have access to any accounts.

 

Any help would be appreciated as I have been at this for over a week and still feel like I am going in circles.

  • August 09, 2010
  • Like
  • 0