• TeraMc
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

I have downloaded the application Advanced Call Scripting and it works great. The only problem I have is that for each question there is a field labeled "Save to Field". I have tried entering the Field Lable, Field Name and the API Name and none of these work.

This will be great functionality if I can get it to work. Has anyone experienced this problem with the application?

  • September 15, 2010
  • Like
  • 0

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

I am running an Enterprise Edition trial for a client. We do not have a sandbox, so I am very wary of implementing a trigger as there is no place to test it.

 

I have a custom field called "Follow up date" on the opportunity object. When an open activity is created, I would like a trigger to update the Follow up date to be the due date of the activity. If there is more than one activity, I would like it to be the next upcoming due date.

 

If anyone has links to examples of a trigger like this, I would appreciate the help.

 

Thank you.

  • February 24, 2010
  • Like
  • 0

The Type field is causing problems for me on Activity/Tasks. This field is key for me as I need to write validation rules for Activities that are Calls vs. Email.

 

The standard functionality is that Type defaults to nothing wether you click "Log a Call" or "New Task". I have been able to update this, but now both default to "Call".

 

I have added the Type field to my Activity page layout, however even though it shows as being there in Setup, when I go to the actual page, the field does not show.

 

What I would like to happen is, when I click "Log a Call", the Type = Call. When New Task is clicked Type = Other.

  • February 05, 2010
  • Like
  • 0

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

Hello all,

 

I have a small question here on how to send an email(with specific template) when a button is clicked.

 

Could anybody please help me out doing the following:

 

1. Create a button "Send Email" on opportunity page. 

2. when the button is clicked, an email should be sent to the contact related to that opportunity with a specific email template.

 

 Any small pointers how to do this will be appreciated.

 

Thanks a lot! 

  • December 06, 2009
  • Like
  • 0
We have experienced a change in the SFDC environment with respect to accounts and opportunities. Currently and in the past, we have a PHP process which transfers accounts to various owners based on an outside system we have for master accounts.

In the past, the opportunities that were active would automatically move over with the change via the API. Now, they are not. Is this a change in the way that SFDC handles these ownership changes? Is there anything we can do to mitigate it? It’s causing a lot of data integrity issues on our end.

We think the change occurred around Mindfully to Mid-August. However, it took us until September to realize that it was happening though, after a bunch of records weren't being swapped over

I cannot find anything in the API documentation about this.  This is really urgent and is causing us to have to fix these issues manually when it has never happened in the past.