• Nick Keehan
  • NEWBIE
  • 160 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 27
    Replies
Hey guys.

Looking for some help with my JS firing.

Oncomplete doesnt seem to fire my script. Any Ideas?
 
<apex:page controller="SubmitLeadController" showHeader="false"  >
<html>
    <apex:form >
        <apex:pageMessages />
        
     
    <body> 
        
        <table style="width:800px; margin: 20px;" >
    <apex:slds />





         <tr >
         <th style="padding: 10px; text-align: left;">Request Details</th>
         </tr>   

            
              <tr style="border-bottom: 1px solid #ddd;" >
                <th style="padding: 10px; text-align: left; font-weight: normal;">Request Type</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Request_Type__c}" id="Request_Type__c" required="true" style="width:200px;"/></td>
            </tr>              
              
 
         <tr >
         <th style="padding: 10px; text-align: left;">Customer Details</th>
         </tr>         
          
          
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">CRM type</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.CRM__c}" id="CRM__c" required="true" style="width:200px;"/></td>
            </tr>
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Customers Account Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Account_number__c}" id="Account_Number__c" required="true" style="width:200px;"/></td>
            </tr>
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">First Name:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.FirstName}" id="FirstName" required="true" style="width:200px;"/></td>
            </tr>
   
   
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Last Name:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.LastName}" id="LastName" required="true" style="width:200px;"/></td>
            </tr>  
            
            
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Email Address:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Email}" id="Email" style="width:200px;"/></td>
            </tr>             
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Contact Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Phone}" id="Phone" required="true" style="width:200px;"/></td>
            </tr>
 
 
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Alternative Contact Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Alternative_Phone_No__c}" id="Alternative_Phone_No__c"  style="width:200px;"/></td>
            </tr>
 
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Callback Time</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Best_Time_To_Call__c}" id="Best_Time_To_Call__c" required="true" style="width:200px;"/></td>
            </tr>              
 
 
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Current Broadband Provider</th>
                <td style="padding: 10px; text-align: left;"><apex:inputtext value="{!c.Broadband_Provider_Details__c}" id="Broadband_Provider_Details__c" required="true" style="width:200px;"/></td>
            </tr>  
 
            
            <tr>
                <th style="padding: 10px; text-align: left; font-weight: normal;">Contract Status</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_Status__c}" id="Contract_Status__c"  style="width:200px;"/> </td>                              
            </tr>    
  
  
             <tr  >    
                <th style="padding: 10px; text-align: left; font-weight: normal;"></th>               
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_end_date__c}" id="Contract_end_date__c"  style="width:200px;" /></td>                    
             </tr>
 
              <tr style="border-bottom: 1px solid #ddd;" id="test1">    
                <th style="padding: 10px; text-align: left; font-weight: normal;"></th>               
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_End_Date_Call_Back_Year__c}" id="Contract_End_Date_Call_Back_Year__c2" style="width:200px;" /></td>                     
             </tr>
 
            

             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Notes - Be as clear as possible for the person picking up this call-back</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Comments__c}" id="Comments__c" style="width:200px;" /></td>
            </tr>           
            
            
            
                        <tr style="border-bottom: 1px solid #ddd;" >
                <th style="padding: 10px; text-align: left; font-weight: normal;">Your Email Address: </th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Referred_By_Email__c}" id="Referred_by_email__c" required="true" style="width:200px;"/></td>
            </tr>      
                  
                  
       <!-- ***** Marketo embed snippet ***** -->
    <!-- Marketo embed script -->
    <script src="//app-sn04.marketo.com/js/forms2/js/forms2.min.js"></script>
    <script type="text/javascript">
        (function() {
            var didInit = false;
            function initMunchkin() {
                if (didInit === false) {
                    didInit = true;
                    Munchkin.init('727-LUR-661');
                }
            }
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = '//munchkin.marketo.net/munchkin.js';
            s.onreadystatechange = function() {
                if (this.readyState == 'complete' || this.readyState == 'loaded') {
                    initMunchkin();
                }
            };
            s.onload = initMunchkin;
            document.getElementsByTagName('head')[0].appendChild(s);
        })();
        var m_obj = [];
        MktoForms2.loadForm("//app-sn04.marketo.com", "727-LUR-661", 1052, function (form) {
            m_obj.form = form;
        }).whenReady(function (form) {
            form.onSuccess(function (values, followUpUrl) {
                console.log(values); // FOR DEBUGGING - REMOVE WHEN NEEDED
                return false;
            });
        });
        function m_submit() {
            m_obj.form.setValues({
                "CallBackForm_ClarifyBillingAccountID": document.getElementById("Account_number__c").value, // Clarify Account Number
                "FirstName": document.getElementById("FirstName").value, // First Name
                "LastName": document.getElementById("LastName").value, // Last Name
                "callBackFormBroadbandProviderDetails": document.getElementById("Broadband_Provider_Details__c").value, // Current Broadband Provider
                "callBackFormContractenddate": document.getElementById("Contract_end_date__c").value, // Contract End Date
                "callBackFormContractEndYear": document.getElementById("Contract_End_Date_Call_Back_Year__c").value, // Contract End Year
                "callBackFormPhoneNumber": document.getElementById("phone").value, // Contact number
                "callBackFormAltPhoneNumber": document.getElementById("Alternative_Phone_No__c").value, // Alternative Contact Number
                "callBackFormCallBackTime": document.getElementById("Best_Time_To_Call__c").value, // Best Time to Call
                "callBackFormRequestType": document.getElementById("Request_Type__c").value, // Customers Request
                "callBackFormComments": document.getElementById("Comments__c").value, // Notes
                "Email": document.getElementById("Email").value, // Email
                //"callBackFormReferredByEmail": document.getElementById("Referred_By_Email__c").value, // referred by email (unsure of source)
            });
            m_obj.form.submit();
        }
    </script>
    <!-- Marketo Form -->
    <form id="mktoForm_1052" style="display:none"></form>
    <!-- ***** END Marketo embed snippet ***** -->               
  
   
                  
                  
            <tr>
                <td style="padding: 10px; text-align: left;"><apex:commandButton value="Submit Call-Back" action="{!submitCase}" onclick="m_submit();" /></td>
            </tr>


    
        </table>  
              
          </body>       
  
  

        
    </apex:form>
  </html>  
</apex:page>

 
hi guys.

Having issue with this Test Class's code coverage. Should be at 100% but sitting at 54%

Class.AccExtension2.Save: line 52, column 1
Class.AccExtension2Test.testVodafoneFab: line 67, column 1

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

Test Class - Highlighted fields below seem to be the issue (or the If statement). All three are External ID's and Unique. 

Any Suggestions? 
@isTest 
public class AccExtension2Test 
{
    static testMethod void testCustomerRowID() 
    {
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999997,399999997,1-999997,1-999999997';
        testAccount.Siebel_Customer_Row_ID__c = '1-0000003';    
        testAccount.Clarify_Billing_Account_ID__c = '987873287' ;      
        testAccount.Siebel_Customer_Row_ID__c = '319909009';
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = '239879898';
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
    }
     static testMethod void testVodafoneFab() {
        //create case
        Case C = new Case();
        C.Subject = 'test';
        insert C;
        system.assert(C.id != null);
        
        //get case number
        Case CS = [select CaseNumber from Case where id =: C.id];
        
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999989,399999678,1-999678,1-999999678';
        testAccount.Siebel_Customer_Row_ID__c = '1-0009999';    
        testAccount.Vodafone_FAB_Account_Number__c = '8806463614' ;    
        testAccount.Clarify_Billing_Account_ID__c = '879877896' ;      
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = CS.CaseNumber;
        testAccount.Worksheet_ID__c = '2BArQ36pR8xz4Ktq6s';
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
        
    }
    
    static testMethod void testNoCustomerRowIDVodafoneTab() {
        //create case
        Case C = new Case();
        C.Subject = 'test';
        insert C;
        system.assert(C.id != null);
        
        //get case number
        Case CS = [select CaseNumber from Case where id =: C.id];
        
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999999,399999999,1-999999,1-999999999';
        testAccount.Siebel_Customer_Row_ID__c = '1-0000000';    
        testAccount.Clarify_Billing_Account_ID__c = '2BArQ36pR8xz4Ktq6s' ;      
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = CS.CaseNumber;
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
        
    }
}


Class
public class AccExtension2 {

private final Account objacc;


    public AccExtension2(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
                                          

     Account cust = new Account();   
     Case cse = new Case();      
     Case MyCase = new Case();       
     Account bill = new Account();  
     Account serv = new Account();
     Opportunity opps = new Opportunity();


public PageReference Save() {
if(objacc.Siebel_Customer_Row_ID__c != null){

        // Top Level Account
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Siebel_Customer_Row_ID__c = objacc.Siebel_Customer_Row_ID__c;           
        cust.RecordTypeId = '012D00000003KdL';
        upsert cust Siebel_Customer_Row_ID__c;

         // Middle Level Account
         bill.LastName= objacc.LastName;
         bill.FirstName= objacc.FirstName;         
         bill.Parent_Account__c = cust.id; 
         bill.Siebel_Billing_Account_ID__c = objacc.Siebel_References__c.substring(9,18);        
         bill.Siebel_References__c = objacc.Siebel_References__c ;                    
         bill.RecordTypeid = '012D00000003KdQ';      
         upsert bill Siebel_Billing_Account_ID__c;

         // Child Account
         serv.LastName= objacc.LastName;
         serv.FirstName= objacc.FirstName;          
         serv.Parent_Account__c = bill.id;
         serv.Product_Names__c = objacc.Product_Names__c;    
         serv.Siebel_References__c = objacc.Siebel_References__c ;                                        
         serv.RecordTypeid = '012D00000003KdV';
         serv.Vodafone_FAB_Account_Number__c = objacc.Vodafone_FAB_Account_Number__c;
         serv.Worksheet_ID__c=  objacc.Worksheet_ID__c;
         serv.Case_Reference__c = objacc.Case_Reference__c;   
         insert serv;
    
    
         // Sale Loaded to Child Account
         opps.AccountId = serv.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeid = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
         return new PageReference('/'+ opps.id); 
         
         }

            else{
            If(objacc.Vodafone_FAB_Account_Number__c != null){

         // Legacy Processes (no parentage)
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Vodafone_FAB_Account_Number__c = objacc.Vodafone_FAB_Account_Number__c ;           
        cust.RecordTypeid = '012200000000iKt';
        cust.Case_Reference__c = objacc.Case_Reference__c;           
        upsert cust Vodafone_FAB_Account_Number__c;} 
            
            else{
        
         // Legacy Processes (no parentage)
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Clarify_Billing_Account_ID__c = objacc.Clarify_Billing_Account_ID__c ;           
        cust.RecordTypeid = '012200000000iKt';
        cust.Case_Reference__c = objacc.Case_Reference__c;           
        upsert cust Clarify_Billing_Account_ID__c ;}

         // Opportunity loaded against Legacy Customer
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                       
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
      
      }
 
 
 
          Case MyCase = new Case(); 
          If(objacc.Case_Reference__c != ''){ 
          MyCase = [Select Id, CaseNumber, subject from Case where CaseNumber = :objacc.Case_Reference__c Limit 1];

          MyCase.Referral_Status__c = 'Success';  
          MyCase.Referral_Type__c = 'New';          
          MyCase.VF_Account_Number_C3__c = objacc.Siebel_Customer_Row_ID__c;         
          update MyCase;
        } 


      
      return new PageReference('/'+ opps.id);


    }

}


 
HI Guys.

Looking for some help writing  a test class. Very basic, just record creation.

Visualforce page is basic, just standard controller Account.

 
public class AccExtension4 {

private final Account objacc;


    public AccExtension4(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
    
     public Account acc {get; set;}
     public Opportunity opp {get; set;} 
     Account cust = new Account();   
     Opportunity opps = new Opportunity();


public PageReference Save() {


       //Add all the class information then insert the class
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Customer_Row_ID__c = objacc.Customer_Row_ID__c;           
        cust.RecordTypeid = '0120E000000aznK';
        upsert cust Customer_Row_ID__c;
    
    
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
 
 
return new PageReference('/'+ opps.id); 
         
         }

    }


I had a look online for an example to use.
This is what has given me a low code coverage.
@isTest 
public class AccExtension2Test 
{
 static testMethod void testMethod1() 
 {
 Account testAccount = new Account();
        testAccount.LastName= 'test last name';
        testAccount.FirstName= 'test first name';
        testAccount.Phone= '021000000'; 
        testAccount.PersonMobilePhone= '021000000'; 
        testAccount.PersonEmail= 'nihan@gmail.com';          
        testAccount.Siebel_References__c = 'tester' ;           
        testAccount.Siebel_Customer_Row_ID__c = '32pkj-32nm';           
        testAccount.RecordTypeid = '012D00000003KdL';
        upsert testAccount Siebel_Customer_Row_ID__c ;



 Test.StartTest(); 
  ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
  AccExtension4 testAccPlan = new AccExtension4(sc);

  PageReference pageRef = Page.FibreSimplex; // Add your VF page Name here
  pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
  Test.setCurrentPage(pageRef);

  //testAccPlan.save(); call all your function here
 Test.StopTest();
 }
}

 
Hopefully quick question.

Keep getting List has no rows error. Tried a couple of suggestions online like size however my Mycase.Referral_Status__c errors with Method not found. 

Hopefully easy enough to fihure out the issue. The below is under my Save() function. (objacc is referenced on the vf page)
Case MyCase = [Select Id, CaseNumber from Case where CaseNumber = :objacc.Case_Reference__c];
         
 if(MyCase != null){

        MyCase.Referral_Status__c = 'Success';  
        MyCase.Referral_Type__c = 'New';          
        MyCase.VF_Account_Number_C3__c = objacc.Customer_Row_ID__c;         
        update MyCase;
        } 
        else {
           return null;
        }

 
HI Guys.

Cant seem to get the Opportunities to appear under the child accounts when querying with the below codes. I can get all opportunities associated to the parent account however not able to display the Opportunites under the child accounts.

Any help would be awesome, see below for codes.

SOQL Query
public class GetAccountContacts {        
    public List<Account> getAccConCases(){
        return [select id, Name, Siebel_Row_Id__c, Parent_Accounts__c, (select id, Name from Account.Contacts) , (select id, Name from Account.Child_Accounts__r), (select id, CaseNumber from Cases), (select id, Name, AccountId from Account.Opportunities) from account where (Siebel_Row_Id__c != null Or Parent_Accounts__c != null)      LIMIT 10];
    }                   
}
VF Page displaying the results. Works like a tree map. 
<apex:repeat value="{!AccConCases}" var="a">
            <ul>
                <li>
                    <span><i class="icon-folder-open icon-plus-sign"></i>Parent Account</span> <a href="/{a.Id}"  target="_blank">{!a.Name}</a>
                    <ul>
                                        
                          <apex:repeat value="{!a.Opportunities}" var="op">
                            <li>
                                <span><i class="glyphicon glyphicon-briefcase"></i> Opportunity</span><a href="/{!op.Id}" target="_blank"></a> {!op.Name}
                            </li>
                          </apex:repeat>   
   
                        
                          <apex:repeat value="{!a.Child_Accounts__r}" var="ch">
                            <li>
                                <span><i class="glyphicon glyphicon-user"></i>Connection Accounts</span><a href="/{!ch.Id}"  target="_blank"></a> {!ch.Name}
                                <ul>
                                
                                    <apex:repeat value="{!a.Opportunities}" var="op">
                                        <li>
                                            <span><i class="glyphicon glyphicon-briefcase"></i> Opp</span><a href="/{!op.Id}" target="_blank"></a> {!op.Name}
                                        </li>
                                    </apex:repeat>
                                    
                                </ul>
                            </li>
                        </apex:repeat>                      
                    </ul>
                </li>
            </ul>
        </apex:repeat>

What it looks like currently, im looking to get opportunities to appear under the Child Accounts also.
User-added image
 
Hi Experts

We have serveral partners each with thier own login URL, which we would like to bring into a single shared login screen.

e.g.
myinstance.force.com/partner1/login
​myinstance.force.com/partner2/login

Is there a way to have one single login screen and it login to the correct partner depending on thier username/profile?

e.g.
myinstance.force.com/login

Any help would be apreciated.

Nick
Hey Guys.

I have a page and three group buttons. Each Populates a value {{radioModel}} via a script.

Inputfield wont accept the {{radioModel} output. Is there a way to do this without a Class?

It can populate a <input> value, just not an Apex:Inputfield or Apex:inputText.

Heres my code.

nay help would be apreciated.
 
<body>

<apex:inputField value="{!Object__c.Field__c}" ID="Field__c"/>   
   
{{radioModel}}

    <div class="btn-group">
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'OK" uncheckable="1">OK</label>
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Great'" uncheckable="1">Great</label>
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Perfect"  uncheckable="1">Perfect</label>
    </div>


<script>
  angular.module('ui.bootstrap.demo', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
  angular.module('ui.bootstrap.demo').controller('ButtonsCtrl', function ($scope) {
  $scope.singleModel = 1;
      });
</script>


</body>

 
Hi Guys. 

How do i tell this trigger to do nothing if there is the "Sale__c" is blank on the Interaction. Sale is parent, interaction is child.

Works fine if there is a Sale__c attached to the interaction, doesnt work otherwise.


ERROR
caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
 
Trigger.Countchild: line 43, column 1

CODE
trigger Countchild on Interaction__c (after insert, after update) {

   List<Opportunity> OP = new List<Opportunity>();
   
   Set<Id> saleids = new Set<Id>();
   

   if(Trigger.isUpdate) {

     for(Interaction__c test:Trigger.New) {
      
        saleids.add(test.Sale__c);   
    
     }   
   
   }
   else
   {
     for(Interaction__c test:Trigger.New) {
      
        saleids.add(test.Sale__c);   
    
     }
   }
   
   AggregateResult[] groupedResults = [SELECT COUNT(Id), Sale__c FROM Interaction__c where Sale__c IN :saleids GROUP BY Sale__c ];
   
   for(AggregateResult ar:groupedResults) {
     
     Id saleid = (ID)ar.get('Sale__c');
     
     Integer count = (INTEGER)ar.get('expr0');
     
     Opportunity sale1 = new Opportunity(Id=saleid);
     
     sale1.Interaction_Count__c = count;
     
     OP.add(sale1);
      
   }
   
   
if(OP.size() > 0) {
update OP;
}


}


 
I am in the need of a lightning button to Accept a case when either on the detail page view or the list view.

After looking around, there is a apex class option which i could use however i would rather use somethign native. 
Anyone had any luck with anything like this?

Leads have a lightning accept lead function however lightning cases dont appear to.

thanks
Hi Guys.

I have an Input Text Area which is diplaying HTML URL Encoding References.

As this field is looking at a Input text area field on an object, the object is saved correctly without the codes however this page displays with the symbols. Any idea how to remove them? 


User-added image

Thanks

 
Hi Guys.

Have made External_Id_1__c and External_Id_2__c an external Id today on both the account object and the lead object however when i am deploying this i am still getting the same 200000 non selectable error. Had a read around and everyone mentions as long as i make the field a external Id it should index and allow more than 200000 records to be queried. We have a large data set.

Any ideas?

If an external ID is entered into the lead, it will add the account number into a lookup field is the idea.
trigger SetAccountField on Lead (before insert, before update) {
   
    Set<String> customerCodeSet = new Set<String>(); 
    for (Lead lead : Trigger.new) {
       customerCodeSet.add(Lead.External_Id_1__c); 
    }
    Map<String,Account> customerCodeAccMap = new Map<String,Account>();
    for(Account acc : [Select Id,External_Id_1__c from Account Where External_Id_1__c IN :customerCodeSet]){
        customerCodeAccMap.put(acc.External_Id_1__c,acc);
    }
    for (Lead lead : Trigger.new) {
        if(lead.External_Id_1__c != null && customerCodeAccMap.containsKey(lead.External_Id_1__c))
            lead.Related_Account__c = customerCodeAccMap.get(lead.External_Id_1__c).Id;
    }
   
    
    Set<String> customerCodeSetclarify = new Set<String>(); 
    for (Lead lead : Trigger.new) {
       customerCodeSetclarify.add(Lead.External_Id_2__c); 
    }
    Map<String,Account> customerCodeAccMapclarify = new Map<String,Account>();
    for(Account acc : [Select Id,External_Id_2__c from Account where External_Id_2__c IN :customerCodeSetclarify]){
        customerCodeAccMapclarify.put(acc.External_Id_2__c,acc);
    }
    for (Lead lead : Trigger.new) {
        if(lead.External_Id_2__c != null && customerCodeAccMapclarify.containsKey(lead.External_Id_2__c))
            lead.Related_Account__c = customerCodeAccMapclarify.get(lead.External_Id_2__c).Id;
    }    
    
        
}

 
Hi Guys.

Looking to query records that have been created in the last 7 days and set a boolean as true. The boolean will only render certain records on the VF page repeat function. I will change the Created_Date__c field to 7 days below, this was just the begining.

Getting a "Error: Compile Error: Expression cannot be assigned at line -1 column -1" 
 
public class booleanmap {

public boolean isDisplay {get;set;}

public list<Sales_visit__c> accts {get;set;}

Public Boolean ConditionalDisplay()
{


accts=[SELECT Id, Name, Created_Date__c FROM Sales_Visit__c WHERE Created_Date__c = 'Date.today()'];

        
     if(Sales_Visit__c.Created_Date__c = 'Date.today()')
       {
        isDisplay=True;
       }
       else
        {
          isDisplay=false;
        }

return isDisplay;
}

}

Any help would be apreciated.

Nick
Hi Everyone.

I have a Longitude and Latitude field on a custom object. I am trying to convert the Longitude and Lattitude to a address string in a field.

e.g. -43.5349616 172.6418029
=
String of "219 Tuam Street, Christchurch"

Is this possible? tried the web for this however can only find information on going the other way around street to lat.

Any help would be great
HI Guys.

I have a VF page used top search for a Lead. This will then take the user with the Lead id to another VF page. Once this VF page is complete, i would like it to come back to this search page with the lead still populated.

e.g. search box is a street name, Update the lead via second vf page, then return to original page."tester" is the other VF page.
<apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>
Above brings the user back to the below page, however i would liek it to be still populates with the street name if possible?


VF Page
<apex:page extensions="CreatingWizard2" standardController="Lead" showHeader="false" sidebar="false" standardStylesheets="false" >
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    
<div class="slds"> 

 
<head>
  <title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
</head>   



<apex:form >


<fieldset class="slds-box slds-theme--default slds-container--end">
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Lead Address Search</legend>  
<apex:pageMessages id="showmsg"></apex:pageMessages>

         <div class="slds-form-element">            
         <label class="slds-form-element__label">Street Name</label>
         <div class="slds-form-element__control">
         <apex:inputText value="{!searchstring2}" styleclass="slds-input"/>
         </div>
         <apex:commandButton action="{!search2}" value="Search" styleClass="slds-button slds-button--brand slds-m-top--medium"/>  

</div>

</fieldset>
 
 
 
<fieldset class="slds-box slds-theme--default slds-container--end">     
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Search Results</legend>
<apex:pageBlock rendered="{!or(searchstring != null, searchstring2 != null) }">  

   <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column >  
      <apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>  

     </apex:column>
    </apex:pageBlockTable>   

</apex:pageBlock>  
<apex:actionFunction name="copyAndRerenderDepdPLFields" oncomplete="return copyDepdPLValues('{!$Component.DestID}' ,'{!$Component.SourceID}');" rerender="DestID" />
</fieldset> 


  
<script>
function copyContPLValues (DestContPListID,SourceContPListID) {
    document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
    copyAndRerenderDepdPLFields();
}

function copyDepdPLValues (DestDepdPListID,SourceDepdPListID) {
    document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;
}
</script>

 

</apex:form>            
</div></html>
</apex:page>

Class
public class CreatingWizard2{

public list <lead> acc {get;set;}  
   public string searchstring {get;set;}  
      public string searchstring2 {get;set;} 
   public CreatingWizard2(ApexPages.StandardController controller) {  
   }  
   public void search2(){  
       if(searchstring2 == '' && searchstring == '')
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter an Account Number'));   
     string searchquery='select Lastname,id,Street,Street_Name__c,Street_Number__c from lead where Street_Name__c= :searchstring2 AND Iown__c=True ORDER BY Street_Number__c ASC NULLS LAST Limit 20';  
     acc= Database.query(searchquery);  
   }  
  
 
   public void clear(){  
   acc.clear();  
   }  
 

Lead lead;
 
 
public Lead getLead() {
if(lead == null) lead = new Lead();
return lead;
}

 
    public PageReference create() {
 
         PageReference opptyPage = new PageReference('/001/e?retURL=%2F001%2Fo&RecordType=012200000000iKt&ent=Account');
         opptyPage.setRedirect(true);
 
         return Page.tester;
        } 
 

}



 
Hi Guys.

I am looking to capture the longitude and lattitude when a lead is updated in salesforce via salesforce1.

Ideas:
  • I originally thought a javascript button would work, aparantly Javascript buttons cannot be used in salesforce1.
  • Visualforce page, I can capture on a VF page however the loading of the VF page via salesforce1 is slow and cumbersome as its not part of the app itself.
Does anyone else have any ideas?

Nick
 
Hi Everyone.

According to below, Salesforce1 can cache a users recently accessed records. The issue i have is that i want to cache records assigned to a user rather than accessed ones.
e.g. Assigned to agent in last 2 weeks. Cache these records. 

i had a couple of thoughts,
  1. Have a scheduled apex class that finds records, and updates a checkbox, however im not sure i can "Run as" from apex class.
  2. Have an apex trigger from a new object that an agent can fire from salesforce1 that updates/calls a flow to run an update on all prospects owned by agent less than two weeks old.
https://help.salesforce.com/HTViewHelpDoc?id=customize_sf1_offline_view.htm&language=en_US

Anyone else know how i could achieve this from salesforce1? 

Basically need a way of mass updating record from the running user in salesforce1.

Nick
Hey Guys.

Does anyone know how to conditionally display markers on a google map? e.g. User.Location.CreatedDate > 13/09/2016?

i have below on the user layout which could have multiple locations records.

any direction would be great.
<apex:page standardController="User">

  <!-- This page must be accessed with an Account Id in the URL. For example: 
       https://<salesforceInstance>/apex/NearbyContacts?id=001D000000JRBet -->
  
  <apex:pageBlock >
    <apex:pageBlockSection title="locations For {! User.Name }">
    
     <apex:dataList value="{! User.Locations__r }" var="location">
       <apex:outputText value="{! location.Lead_Address__c}" />
     </apex:dataList> 
    
    </apex:pageBlockSection>
  </apex:pageBlock>
   
  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="-43.5350071 172.64177229999999">


        <apex:repeat value="{! User.Locations__r }" var="location">
        <apex:mapMarker title="{! location.Name }" position="{!contact.Location_Text__c}"/>
        </apex:repeat>

  </apex:map>
  </apex:page>

 
Hi Guys.

Struggling to find a code that will work, i have an object called "Sales_Visits__c" and i would like to set some criteria to show all Sales_Visits in the past 30 days on a map. On the sales visit record is a geolocation.

I can add a map to the record layout however this will only show the single address not multiple on a criteria.

Any thoughts on how i would do this?

Nick
Hey Guys.

Can anyone help with adding a condition for below to fire?

e.g.  if(opp.Product_Name_String__c != '') 

This should only fire when there is something added into Product Name String.

Its mentioned below however it still fires when the string field is empty?

Any ideas?
 
trigger oppLineItem on Opportunity (after insert) {
    Map<id,Set<id>> oppIdProNameMap = new Map<id,Set<Id>>();
    Set<Id> priceBookIdSet = new Set<id>();

    {
    for(Opportunity opp : trigger.new)
        {
        priceBookIdSet = new Set<Id>();
        system.debug('---opp.Product_Name_String__c--'+opp.Product_Name_String__c);
        if(opp.Product_Name_String__c != '')
        {
            priceBookIdSet=getPriceBookId(opp.Product_Name_String__c,opp.Pricebook2Id); 
            system.debug('---priceBookIdSet---'+priceBookIdSet);
            oppIdProNameMap.put(opp.Id, priceBookIdSet);
        }            
    }
    List<OpportunityLineItem> newLineItemsList = new List<OpportunityLineItem>();
    for(id oppId : oppIdProNameMap.keySet()){
        for(id pBId : oppIdProNameMap.get(oppId)){
            OpportunityLineItem lineItem = new OpportunityLineItem (OpportunityID= oppId,PriceBookEntryID=pBId, quantity=1,TotalPrice = 100,Contract_Term__c ='12');
            newLineItemsList.add(lineItem);
        }    
    }
    insert newLineItemsList;
    } 

    public Set<id> getPriceBookId(string pName,id bookId){
        List<String> proName = new List<String>();
        proName = pName.split(',');        
        Map<id,product2> proIdMap = new Map<id,product2>([Select id from product2 where name IN: proName]);
        system.debug('----proIdMap.keySet()--'+proIdMap.keySet());
        Map<id,PricebookEntry> priceBookMap = new Map<id,PricebookEntry>([SELECT Id,IsActive,Product2Id,UnitPrice FROM PricebookEntry WHERE Product2Id IN: proIdMap.keySet() and Pricebook2Id =: bookId]);
        return priceBookMap.keySet();
    }
}

Thanks
Hi guys.

Looking to create an Apex trigger to fire on the Opportunity to convert a Long Text Area String to opportunityLineItems. I have a pricebook set on the opportunity already, so i think i am looking for a type of map that looks at the pricebook entry from the name and supplies a PricebookEntryID, then creating a loop of Opportunity Line Items with the entrys.

E.g. On Opportunity - Product_Names__c - Product 1, Product 2, Product 3

I can have the string seperated/formated in a number of ways, semi colon, no space etc.

Does anyone have any idea how this would look? sorry, still new with Maps.

Nick
hi guys.

Having issue with this Test Class's code coverage. Should be at 100% but sitting at 54%

Class.AccExtension2.Save: line 52, column 1
Class.AccExtension2Test.testVodafoneFab: line 67, column 1

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

Test Class - Highlighted fields below seem to be the issue (or the If statement). All three are External ID's and Unique. 

Any Suggestions? 
@isTest 
public class AccExtension2Test 
{
    static testMethod void testCustomerRowID() 
    {
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999997,399999997,1-999997,1-999999997';
        testAccount.Siebel_Customer_Row_ID__c = '1-0000003';    
        testAccount.Clarify_Billing_Account_ID__c = '987873287' ;      
        testAccount.Siebel_Customer_Row_ID__c = '319909009';
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = '239879898';
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
    }
     static testMethod void testVodafoneFab() {
        //create case
        Case C = new Case();
        C.Subject = 'test';
        insert C;
        system.assert(C.id != null);
        
        //get case number
        Case CS = [select CaseNumber from Case where id =: C.id];
        
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999989,399999678,1-999678,1-999999678';
        testAccount.Siebel_Customer_Row_ID__c = '1-0009999';    
        testAccount.Vodafone_FAB_Account_Number__c = '8806463614' ;    
        testAccount.Clarify_Billing_Account_ID__c = '879877896' ;      
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = CS.CaseNumber;
        testAccount.Worksheet_ID__c = '2BArQ36pR8xz4Ktq6s';
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
        
    }
    
    static testMethod void testNoCustomerRowIDVodafoneTab() {
        //create case
        Case C = new Case();
        C.Subject = 'test';
        insert C;
        system.assert(C.id != null);
        
        //get case number
        Case CS = [select CaseNumber from Case where id =: C.id];
        
        //Create Account
        Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Siebel Customer Account').getRecordTypeId();
        Account testAccount = new Account();
        testAccount.LastName= 'Last Name';
        testAccount.FirstName= 'First Name';
        testAccount.Phone = '9999999999';
        testAccount.PersonEmail = 'test@testmail.com';
        testAccount.RecordTypeid = devRecordTypeId;             
        testAccount.Siebel_References__c = '1-999999,399999999,1-999999,1-999999999';
        testAccount.Siebel_Customer_Row_ID__c = '1-0000000';    
        testAccount.Clarify_Billing_Account_ID__c = '2BArQ36pR8xz4Ktq6s' ;      
        testAccount.Product_Names__c = 'Test Product';
        testAccount.Case_Reference__c = CS.CaseNumber;
        insert testAccount;
        
        system.assertEquals(testAccount.Phone, '9999999999');
        system.assert(testAccount.id != null);
        
        Test.StartTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        AccExtension2 testAccPlan = new AccExtension2(sc);
        testAccPlan.save();
        
        Test.StopTest();
        
    }
}


Class
public class AccExtension2 {

private final Account objacc;


    public AccExtension2(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
                                          

     Account cust = new Account();   
     Case cse = new Case();      
     Case MyCase = new Case();       
     Account bill = new Account();  
     Account serv = new Account();
     Opportunity opps = new Opportunity();


public PageReference Save() {
if(objacc.Siebel_Customer_Row_ID__c != null){

        // Top Level Account
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Siebel_Customer_Row_ID__c = objacc.Siebel_Customer_Row_ID__c;           
        cust.RecordTypeId = '012D00000003KdL';
        upsert cust Siebel_Customer_Row_ID__c;

         // Middle Level Account
         bill.LastName= objacc.LastName;
         bill.FirstName= objacc.FirstName;         
         bill.Parent_Account__c = cust.id; 
         bill.Siebel_Billing_Account_ID__c = objacc.Siebel_References__c.substring(9,18);        
         bill.Siebel_References__c = objacc.Siebel_References__c ;                    
         bill.RecordTypeid = '012D00000003KdQ';      
         upsert bill Siebel_Billing_Account_ID__c;

         // Child Account
         serv.LastName= objacc.LastName;
         serv.FirstName= objacc.FirstName;          
         serv.Parent_Account__c = bill.id;
         serv.Product_Names__c = objacc.Product_Names__c;    
         serv.Siebel_References__c = objacc.Siebel_References__c ;                                        
         serv.RecordTypeid = '012D00000003KdV';
         serv.Vodafone_FAB_Account_Number__c = objacc.Vodafone_FAB_Account_Number__c;
         serv.Worksheet_ID__c=  objacc.Worksheet_ID__c;
         serv.Case_Reference__c = objacc.Case_Reference__c;   
         insert serv;
    
    
         // Sale Loaded to Child Account
         opps.AccountId = serv.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeid = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
         return new PageReference('/'+ opps.id); 
         
         }

            else{
            If(objacc.Vodafone_FAB_Account_Number__c != null){

         // Legacy Processes (no parentage)
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Vodafone_FAB_Account_Number__c = objacc.Vodafone_FAB_Account_Number__c ;           
        cust.RecordTypeid = '012200000000iKt';
        cust.Case_Reference__c = objacc.Case_Reference__c;           
        upsert cust Vodafone_FAB_Account_Number__c;} 
            
            else{
        
         // Legacy Processes (no parentage)
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Clarify_Billing_Account_ID__c = objacc.Clarify_Billing_Account_ID__c ;           
        cust.RecordTypeid = '012200000000iKt';
        cust.Case_Reference__c = objacc.Case_Reference__c;           
        upsert cust Clarify_Billing_Account_ID__c ;}

         // Opportunity loaded against Legacy Customer
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                       
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
      
      }
 
 
 
          Case MyCase = new Case(); 
          If(objacc.Case_Reference__c != ''){ 
          MyCase = [Select Id, CaseNumber, subject from Case where CaseNumber = :objacc.Case_Reference__c Limit 1];

          MyCase.Referral_Status__c = 'Success';  
          MyCase.Referral_Type__c = 'New';          
          MyCase.VF_Account_Number_C3__c = objacc.Siebel_Customer_Row_ID__c;         
          update MyCase;
        } 


      
      return new PageReference('/'+ opps.id);


    }

}


 
HI Guys.

Looking for some help writing  a test class. Very basic, just record creation.

Visualforce page is basic, just standard controller Account.

 
public class AccExtension4 {

private final Account objacc;


    public AccExtension4(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
    
     public Account acc {get; set;}
     public Opportunity opp {get; set;} 
     Account cust = new Account();   
     Opportunity opps = new Opportunity();


public PageReference Save() {


       //Add all the class information then insert the class
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Customer_Row_ID__c = objacc.Customer_Row_ID__c;           
        cust.RecordTypeid = '0120E000000aznK';
        upsert cust Customer_Row_ID__c;
    
    
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
 
 
return new PageReference('/'+ opps.id); 
         
         }

    }


I had a look online for an example to use.
This is what has given me a low code coverage.
@isTest 
public class AccExtension2Test 
{
 static testMethod void testMethod1() 
 {
 Account testAccount = new Account();
        testAccount.LastName= 'test last name';
        testAccount.FirstName= 'test first name';
        testAccount.Phone= '021000000'; 
        testAccount.PersonMobilePhone= '021000000'; 
        testAccount.PersonEmail= 'nihan@gmail.com';          
        testAccount.Siebel_References__c = 'tester' ;           
        testAccount.Siebel_Customer_Row_ID__c = '32pkj-32nm';           
        testAccount.RecordTypeid = '012D00000003KdL';
        upsert testAccount Siebel_Customer_Row_ID__c ;



 Test.StartTest(); 
  ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
  AccExtension4 testAccPlan = new AccExtension4(sc);

  PageReference pageRef = Page.FibreSimplex; // Add your VF page Name here
  pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
  Test.setCurrentPage(pageRef);

  //testAccPlan.save(); call all your function here
 Test.StopTest();
 }
}

 
Hopefully quick question.

Keep getting List has no rows error. Tried a couple of suggestions online like size however my Mycase.Referral_Status__c errors with Method not found. 

Hopefully easy enough to fihure out the issue. The below is under my Save() function. (objacc is referenced on the vf page)
Case MyCase = [Select Id, CaseNumber from Case where CaseNumber = :objacc.Case_Reference__c];
         
 if(MyCase != null){

        MyCase.Referral_Status__c = 'Success';  
        MyCase.Referral_Type__c = 'New';          
        MyCase.VF_Account_Number_C3__c = objacc.Customer_Row_ID__c;         
        update MyCase;
        } 
        else {
           return null;
        }

 
Hey Guys.

I have a page and three group buttons. Each Populates a value {{radioModel}} via a script.

Inputfield wont accept the {{radioModel} output. Is there a way to do this without a Class?

It can populate a <input> value, just not an Apex:Inputfield or Apex:inputText.

Heres my code.

nay help would be apreciated.
 
<body>

<apex:inputField value="{!Object__c.Field__c}" ID="Field__c"/>   
   
{{radioModel}}

    <div class="btn-group">
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'OK" uncheckable="1">OK</label>
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Great'" uncheckable="1">Great</label>
        <label style="background-color:#22A7F0;color:black;width:33%;height:50px;white-space: normal;" class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Perfect"  uncheckable="1">Perfect</label>
    </div>


<script>
  angular.module('ui.bootstrap.demo', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
  angular.module('ui.bootstrap.demo').controller('ButtonsCtrl', function ($scope) {
  $scope.singleModel = 1;
      });
</script>


</body>

 
Hi Guys. 

How do i tell this trigger to do nothing if there is the "Sale__c" is blank on the Interaction. Sale is parent, interaction is child.

Works fine if there is a Sale__c attached to the interaction, doesnt work otherwise.


ERROR
caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
 
Trigger.Countchild: line 43, column 1

CODE
trigger Countchild on Interaction__c (after insert, after update) {

   List<Opportunity> OP = new List<Opportunity>();
   
   Set<Id> saleids = new Set<Id>();
   

   if(Trigger.isUpdate) {

     for(Interaction__c test:Trigger.New) {
      
        saleids.add(test.Sale__c);   
    
     }   
   
   }
   else
   {
     for(Interaction__c test:Trigger.New) {
      
        saleids.add(test.Sale__c);   
    
     }
   }
   
   AggregateResult[] groupedResults = [SELECT COUNT(Id), Sale__c FROM Interaction__c where Sale__c IN :saleids GROUP BY Sale__c ];
   
   for(AggregateResult ar:groupedResults) {
     
     Id saleid = (ID)ar.get('Sale__c');
     
     Integer count = (INTEGER)ar.get('expr0');
     
     Opportunity sale1 = new Opportunity(Id=saleid);
     
     sale1.Interaction_Count__c = count;
     
     OP.add(sale1);
      
   }
   
   
if(OP.size() > 0) {
update OP;
}


}


 
Hi Guys.

Looking to query records that have been created in the last 7 days and set a boolean as true. The boolean will only render certain records on the VF page repeat function. I will change the Created_Date__c field to 7 days below, this was just the begining.

Getting a "Error: Compile Error: Expression cannot be assigned at line -1 column -1" 
 
public class booleanmap {

public boolean isDisplay {get;set;}

public list<Sales_visit__c> accts {get;set;}

Public Boolean ConditionalDisplay()
{


accts=[SELECT Id, Name, Created_Date__c FROM Sales_Visit__c WHERE Created_Date__c = 'Date.today()'];

        
     if(Sales_Visit__c.Created_Date__c = 'Date.today()')
       {
        isDisplay=True;
       }
       else
        {
          isDisplay=false;
        }

return isDisplay;
}

}

Any help would be apreciated.

Nick
HI Guys.

I have a VF page used top search for a Lead. This will then take the user with the Lead id to another VF page. Once this VF page is complete, i would like it to come back to this search page with the lead still populated.

e.g. search box is a street name, Update the lead via second vf page, then return to original page."tester" is the other VF page.
<apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>
Above brings the user back to the below page, however i would liek it to be still populates with the street name if possible?


VF Page
<apex:page extensions="CreatingWizard2" standardController="Lead" showHeader="false" sidebar="false" standardStylesheets="false" >
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    
<div class="slds"> 

 
<head>
  <title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
</head>   



<apex:form >


<fieldset class="slds-box slds-theme--default slds-container--end">
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Lead Address Search</legend>  
<apex:pageMessages id="showmsg"></apex:pageMessages>

         <div class="slds-form-element">            
         <label class="slds-form-element__label">Street Name</label>
         <div class="slds-form-element__control">
         <apex:inputText value="{!searchstring2}" styleclass="slds-input"/>
         </div>
         <apex:commandButton action="{!search2}" value="Search" styleClass="slds-button slds-button--brand slds-m-top--medium"/>  

</div>

</fieldset>
 
 
 
<fieldset class="slds-box slds-theme--default slds-container--end">     
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Search Results</legend>
<apex:pageBlock rendered="{!or(searchstring != null, searchstring2 != null) }">  

   <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column >  
      <apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>  

     </apex:column>
    </apex:pageBlockTable>   

</apex:pageBlock>  
<apex:actionFunction name="copyAndRerenderDepdPLFields" oncomplete="return copyDepdPLValues('{!$Component.DestID}' ,'{!$Component.SourceID}');" rerender="DestID" />
</fieldset> 


  
<script>
function copyContPLValues (DestContPListID,SourceContPListID) {
    document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
    copyAndRerenderDepdPLFields();
}

function copyDepdPLValues (DestDepdPListID,SourceDepdPListID) {
    document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;
}
</script>

 

</apex:form>            
</div></html>
</apex:page>

Class
public class CreatingWizard2{

public list <lead> acc {get;set;}  
   public string searchstring {get;set;}  
      public string searchstring2 {get;set;} 
   public CreatingWizard2(ApexPages.StandardController controller) {  
   }  
   public void search2(){  
       if(searchstring2 == '' && searchstring == '')
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter an Account Number'));   
     string searchquery='select Lastname,id,Street,Street_Name__c,Street_Number__c from lead where Street_Name__c= :searchstring2 AND Iown__c=True ORDER BY Street_Number__c ASC NULLS LAST Limit 20';  
     acc= Database.query(searchquery);  
   }  
  
 
   public void clear(){  
   acc.clear();  
   }  
 

Lead lead;
 
 
public Lead getLead() {
if(lead == null) lead = new Lead();
return lead;
}

 
    public PageReference create() {
 
         PageReference opptyPage = new PageReference('/001/e?retURL=%2F001%2Fo&RecordType=012200000000iKt&ent=Account');
         opptyPage.setRedirect(true);
 
         return Page.tester;
        } 
 

}



 
Hey Guys.

Does anyone know how to conditionally display markers on a google map? e.g. User.Location.CreatedDate > 13/09/2016?

i have below on the user layout which could have multiple locations records.

any direction would be great.
<apex:page standardController="User">

  <!-- This page must be accessed with an Account Id in the URL. For example: 
       https://<salesforceInstance>/apex/NearbyContacts?id=001D000000JRBet -->
  
  <apex:pageBlock >
    <apex:pageBlockSection title="locations For {! User.Name }">
    
     <apex:dataList value="{! User.Locations__r }" var="location">
       <apex:outputText value="{! location.Lead_Address__c}" />
     </apex:dataList> 
    
    </apex:pageBlockSection>
  </apex:pageBlock>
   
  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="-43.5350071 172.64177229999999">


        <apex:repeat value="{! User.Locations__r }" var="location">
        <apex:mapMarker title="{! location.Name }" position="{!contact.Location_Text__c}"/>
        </apex:repeat>

  </apex:map>
  </apex:page>

 
Hey Guys.

Can anyone help with adding a condition for below to fire?

e.g.  if(opp.Product_Name_String__c != '') 

This should only fire when there is something added into Product Name String.

Its mentioned below however it still fires when the string field is empty?

Any ideas?
 
trigger oppLineItem on Opportunity (after insert) {
    Map<id,Set<id>> oppIdProNameMap = new Map<id,Set<Id>>();
    Set<Id> priceBookIdSet = new Set<id>();

    {
    for(Opportunity opp : trigger.new)
        {
        priceBookIdSet = new Set<Id>();
        system.debug('---opp.Product_Name_String__c--'+opp.Product_Name_String__c);
        if(opp.Product_Name_String__c != '')
        {
            priceBookIdSet=getPriceBookId(opp.Product_Name_String__c,opp.Pricebook2Id); 
            system.debug('---priceBookIdSet---'+priceBookIdSet);
            oppIdProNameMap.put(opp.Id, priceBookIdSet);
        }            
    }
    List<OpportunityLineItem> newLineItemsList = new List<OpportunityLineItem>();
    for(id oppId : oppIdProNameMap.keySet()){
        for(id pBId : oppIdProNameMap.get(oppId)){
            OpportunityLineItem lineItem = new OpportunityLineItem (OpportunityID= oppId,PriceBookEntryID=pBId, quantity=1,TotalPrice = 100,Contract_Term__c ='12');
            newLineItemsList.add(lineItem);
        }    
    }
    insert newLineItemsList;
    } 

    public Set<id> getPriceBookId(string pName,id bookId){
        List<String> proName = new List<String>();
        proName = pName.split(',');        
        Map<id,product2> proIdMap = new Map<id,product2>([Select id from product2 where name IN: proName]);
        system.debug('----proIdMap.keySet()--'+proIdMap.keySet());
        Map<id,PricebookEntry> priceBookMap = new Map<id,PricebookEntry>([SELECT Id,IsActive,Product2Id,UnitPrice FROM PricebookEntry WHERE Product2Id IN: proIdMap.keySet() and Pricebook2Id =: bookId]);
        return priceBookMap.keySet();
    }
}

Thanks
Hi guys.

Looking to create an Apex trigger to fire on the Opportunity to convert a Long Text Area String to opportunityLineItems. I have a pricebook set on the opportunity already, so i think i am looking for a type of map that looks at the pricebook entry from the name and supplies a PricebookEntryID, then creating a loop of Opportunity Line Items with the entrys.

E.g. On Opportunity - Product_Names__c - Product 1, Product 2, Product 3

I can have the string seperated/formated in a number of ways, semi colon, no space etc.

Does anyone have any idea how this would look? sorry, still new with Maps.

Nick
Hi Guys.

Hoping someone can point me in the right direction for a Apex test to test a VF page and controller that basically searches for an account, then a Output link url goes to the customer edit page. I am relitively new to apex and cant get anything above 5% coverage with major editing of the apex class. 

An acacount number is entered into one of two fields, the page searches for accounts with that reference and rerenders the page, the page block table provides the account to be selected which is an output link the customer edit page.

Any suggestions/help would be really apreciated.

VF Page
<apex:page extensions="CreatingWizard2" standardController="Account" showHeader="false" sidebar="false" standardStylesheets="false" >
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    
<div class="slds"> 


<div class="slds-box slds-theme--alt-inverse">
  <p>
    <strong>Salesforce Step 1</strong> - Search/Create Customer</p>
</div>


 
<head>
  <title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
</head>   



<apex:form >


<fieldset class="slds-box slds-theme--default slds-container--end">
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Existing Customer Account Search</legend>  
<apex:pageMessages id="showmsg"></apex:pageMessages>

         <div class="slds-p-around--x-large">
         <div class="slds-form-element">            
         <label class="slds-form-element__label">TP2 Billing Account Number</label>
         <div class="slds-form-element__control">
         <apex:inputText value="{!searchstring2}" styleclass="slds-input"/>
         </div>
         <apex:commandButton action="{!search3}" value="Search TP2" styleClass="slds-button slds-button--brand slds-m-top--medium"/>  

</div></div>
<div class="slds-p-around--x-large">
      <div class="slds-form-element">            
        <label class="slds-form-element__label">Clarify Billing Account ID</label>
                <div class="slds-form-element__control">
          <apex:inputText value="{!searchstring}" styleclass="slds-input"/>
        </div>

<apex:commandButton action="{!search2}" value="Search Clarify" styleClass="slds-button slds-button--brand slds-m-top--medium"/>  
</div></div>
</fieldset>
 
 
 
<fieldset class="slds-box slds-theme--default slds-container--end">     
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Search Results</legend>
<apex:pageBlock rendered="{!or(searchstring != null, searchstring2 != null) }">  

   <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column >  
      <apex:outputlink value="https://cs86.salesforce.com/{!a.id}/e?&00N7E000000dD7X=1">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column value="{!a.phone}"/>  
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>   
  
   <apex:commandButton action="https://cs86.salesforce.com/001/e?retURL=%2F001%2Fo&RecordType=012200000000iKt&ent=Account&00N7E000000dD7X=1" value="Create a Customer" styleClass="slds-button slds-button--brand slds-m-top--medium"/>   
</apex:pageBlock>  

    <apex:actionFunction name="copyAndRerenderDepdPLFields" oncomplete="return copyDepdPLValues('{!$Component.DestID}' ,'{!$Component.SourceID}');" rerender="DestID" />
</fieldset> 


  
<script>
function copyContPLValues (DestContPListID,SourceContPListID) {
    document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
    copyAndRerenderDepdPLFields();
}

function copyDepdPLValues (DestDepdPListID,SourceDepdPListID) {
    document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;
}
</script>

 

</apex:form>            
</div></html>
</apex:page>

Apex Class
public class CreatingWizard2{

public list <account> acc {get;set;}  
   public string searchstring {get;set;}  
      public string searchstring2 {get;set;} 
   public CreatingWizard2(ApexPages.StandardController controller) {  
   }  
   public void search2(){  
       if(searchstring2 == '' && searchstring == '')
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter an Account Number'));   
     string searchquery='select name,id,Clarify_Billing_Account_ID__c, phone, PersonMobilePhone from account where Clarify_Billing_Account_ID__c != null AND Clarify_Billing_Account_ID__c = :searchstring Limit 20';  
     acc= Database.query(searchquery);  
   }  
   
   public void search3(){  
       if(searchstring2 == '' && searchstring == '')
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter an Account Number'));   
     string searchquery='select name,id,Vodafone_FAB_Account_Number__c, phone, PersonMobilePhone from account where Vodafone_FAB_Account_Number__c != null AND Vodafone_FAB_Account_Number__c = :searchstring2 Limit 20';  
     acc= Database.query(searchquery);  
   }     
   
   
   public void clear(){  
   acc.clear();  
   }  
 

Account account;
 
 
public Account getAccount() {
if(account == null) account = new Account();
return account;
}

 
    public PageReference create() {
 
         PageReference opptyPage;
         opptyPage.setRedirect(true);
 
         return Page.resigns;
        } 
 

}


 
Hi Guys.

The below code will create an account fine, however it will not allow me to add an opportunity to the account with the error "System.NullPointerException: Attempt to de-reference a null object".

It is erroring at Opportunity.name (first line or opp)

Turned debug on however still cant see whats causing this. any ideas?

Apex Class
 
public class CreatingWizard{
 
Contact contact; 
Account account;
Opportunity opportunity;
OpportunityContactRole role;
 
public Contact getContact() {
if(contact == null) contact = new Contact();
return contact;}
 
public Account getAccount() {
if(account == null) account = new Account();
return account;}

public Opportunity getOpportunity() {
if(opportunity == null) opportunity = new Opportunity();
return opportunity;}
 
public OpportunityContactRole getRole() {
if(role == null) role = new OpportunityContactRole();
return role;}
 





   public PageReference createcustomer() {


               contact.LastName = Account.LastName;
               contact.FirstName = Contact.FirstName;
               insert contact;  


               account.LastName = Account.LastName;
               account.FirstName = Contact.FirstName;
               account.Phone = Account.Phone;
               account.PersonMobilePhone = Account.PersonMobilePhone;
               account.ShippingStreet = Account.ShippingStreet;                                             
               account.RecordTypeID = '012200000000iKt';
               account.Customer_Data_Source__c = 'https://c.cs86.visual.force.com/apex/accoppwizard';
               insert account;     


               opportunity.Name = 'Oneview Resign/Upgrade';
               opportunity.CampaignId = '7017E0000004srD';
               opportunity.CloseDate = system.today();
               opportunity.StageName = 'Closed Won';
               opportunity.accountId = '0017E00000IadeE';
               insert opportunity;  


                role.opportunityId = opportunity.id;
                role.contactId = contact.id;
                insert role;



               PageReference newPage = New PageReference('/'+opportunity.id);
               newPage.setRedirect(true);
               return newPage;
        

       return null;
   }
}

 
Hi Guys.

Looking for help with creating a unique randomly generated password in a field when a record is saved.

Have done some research and cant get any of the solutions working with my limited knowledge.
E.g. http://salesforce.stackexchange.com/questions/43823/how-do-i-generate-a-random-string

Is there a piece of apex code that can acomplish this for me, or has anyone got a suggestion on what page to follow?
Any help would be apreciated.

Nick

 
I wrote and deployed a Test for using a VF page for product line entry.  My Test class worked previously.  Now I am getting a System.Assert Exception error for virtually the same code.  I only added additional required fields for the Opportunity Line Item.  Can anyone help?

Here is the test Class:

@istest (SeeAllData=true)
private class opportunityProductEntryTests {

    static testMethod void theTests(){
       
        // You really should create test data, but I'm going to query instead
        // It's my best shot of avoiding a test failure in most orgs
        // Once you've installed this package though, you might want to write your own tests
        // or at least customize these ones to make them more applicable to your org
           
        OpportunityLineItem oli = [select Id, PricebookEntryId, PricebookEntry.Pricebook2Id, PricebookEntry.Name, PriceBookEntry.Product2Id, OpportunityId, Opportunity.AccountId from OpportunityLineItem limit 1];
              
               
        ////////////////////////////////////////
        //  test opportunityProductEntry
        ////////////////////////////////////////
       
        // load the page      
        PageReference pageRef = Page.opportunityProductEntry;
        pageRef.getParameters().put('Id',oli.OpportunityId);
        system.Test.setCurrentPageReference(pageRef);
       
        // load the extension
        opportunityProductEntryExtension oPEE = new opportunityProductEntryExtension(new ApexPages.StandardController(oli.Opportunity));
       
        // test 'getChosenCurrency' method
        if(UserInfo.isMultiCurrencyOrganization())
            System.assert(oPEE.getChosenCurrency()!='');
        else
            System.assertEquals(oPEE.getChosenCurrency(),'');

        // we know that there is at least one line item, so we confirm
        Integer startCount = oPEE.ShoppingCart.size();
        system.assert(startCount>0);

        //test search functionality without finding anything
        oPEE.searchString = 'michaelforce is a hip cat';
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()==0);
       
        //test remove from shopping cart
        oPEE.toUnselect = oli.PricebookEntryId;
        oPEE.removeFromShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount-1);
       
        //test save and reload extension
        oPEE.onSave();
        oPEE = new opportunityProductEntryExtension(new ApexPages.StandardController(oli.Opportunity));
        system.assert(oPEE.shoppingCart.size()==startCount-1);
       
        // test search again, this time we will find something
        oPEE.searchString = oli.PricebookEntry.Name;
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()>0);      

        // test add to Shopping Cart function
        oPEE.toSelect = oPEE.AvailableProducts[0].Id;
        oPEE.addToShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount);
               
        // test save method - WITHOUT quanitities and amounts entered and confirm that error message is displayed
        oPEE.onSave();
        system.assert(ApexPages.getMessages().size()>0);
       
        // add required info and try save again
        for(OpportunityLineItem o : oPEE.ShoppingCart){
            o.quantity = 5;
            o.unitprice = 300;
            o.Term_Months__c = 12;
            o.Term_on_Product__c = FALSE;
            o.Opportunity_Type__c = 'New Business';
        }
        oPEE.onSave();
       
        // query line items to confirm that the save worked **HERE IS WHERE THE ERROR OCCURS**
        opportunityLineItem[] oli2 = [select Id from opportunityLineItem where OpportunityId = :oli.OpportunityId];
        system.assert(oli2.size()==startCount);
       
        // test on new Opp (no pricebook selected) to make sure redirect is happening
        Opportunity newOpp = new Opportunity(Name='New Opp',stageName='Pipeline',Amount=10,closeDate=System.Today()+30,AccountId=oli.Opportunity.AccountId);
        insert(newOpp);
        oPEE = new opportunityProductEntryExtension(new ApexPages.StandardController(newOpp));
        System.assert(oPEE.priceBookCheck()!=null);
       
        // final quick check of cancel button
        System.assert(oPEE.onCancel()!=null);
       
       
        ////////////////////////////////////////
        //  test redirect page
        ////////////////////////////////////////
       
        // load the page
        pageRef = Page.opportunityProductRedirect;
        pageRef.getParameters().put('Id',oli2[0].Id);
        system.Test.setCurrentPageReference(pageRef);

        // load the extension and confirm that redirect function returns something
        opportunityProductRedirectExtension oPRE = new opportunityProductRedirectExtension(new ApexPages.StandardController(oli2[0]));
        System.assert(oPRE.redirect()!=null);
    
    }

}