• Becky Miller 15
  • NEWBIE
  • 110 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 20
    Questions
  • 28
    Replies
This is our old Page Reference for the Classic: It is creating a new Quote Page and updating certain fields:
PageReference pref =  new PageReference('lightning/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8')  + '&retURL=%2F' + theOpp.id + '&oppid=' + theOpp.Oppty_ID_18__c);

This is our new Page Reference for the Lightning.  It is not populating the Quote Name with Opportunity Name, Opportunity, Account Name.
           
PageReference pref = new PageReference('/lightning/o/Quote/new?Name=' +theOpp.Name+'&retURL=%2F'+ '&oppid=' + theOpp.Oppty_ID_18__c);


Any guidance someone could provide me that would be great.
I am not 100% sure how to change this to be recognized in Lightning.  The Opportunity Name / ID is not being added to the Quote in Lightning.  Works just fine in Classic.  Any guidance would be great.

        if(theOpp.Account.RecordType.Name =='Prospect') {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8')  + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
        else {
            PageReference pref =  new PageReference('/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8') + '&BillingName=' + EncodingUtil.urlEncode(theOpp.Account.Name,'UTF-8') + '&retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id);
            return pref;
        }
Trouble getting any coverage on my test code to cover anything. 

It is a simple Visualforce page of fields already on the Pagelayout but to make it easier for the users.  
The button is on the Account Record and just pulls up the fields the sales team needs to fill out. 

Here is my Apex:
public with sharing class US_Medical_sales_mandatory {
    
    private ApexPages.StandardController c;

  
     public string getAccountId{get;set;}
       
      public US_Medical_sales_mandatory (ApexPages.StandardController controller)
      {
       
          getAccountid = ApexPages.CurrentPage().getparameters().get('ID');
      }
    

    
 public pagereference US_Medical_Sales_Mandatory()
 {

// you can fetch dummy lookup field value here and process accordingly.
  System.debug('@@@@@@@@@@@'+account.ownerid);
  return null;
 } 
}

Here is my test script:
@isTest
public class US_Medical_sales_mandatory_Test {
  
    Static testMethod void US_Medical_sales_mandatory_Test() {
     
         
        Account a = new Account(
            Name = 'testaccount'           );
        insert a;

      Account newAccount = new Account();
        
     Account acc= [Select ID,Name From Account WHERE Name='testaccount'];
      a.Id=acc.Id;
        a.AERs_in_Dept1__c = 'Manual';
        a.AER_s_in_Dept_2__c = 'Cantel ADV + 2.0';
        a.AER_s_in_Dept_3__c = 'Cantel ADV PT';
         a.AER_s_in_Dept_4__c = 'EVOTECH';
         a.AER_s_in_Dept_5__c = 'Cantel ISA';
         a.AER_s_in_Dept_6__c = 'Cantel ISA';
         a.Average_Numbers_of_Rooms__c = 45;
         a.Brush_Brand__c = 'Pull Thru';
         a.Colon_Volume_Yearly__c = 25;
         a.Department_AER_1__c = 'ENT';
         a.Department_AER_2__c =  'GI';
         a.Department_AER_3__c = 'GI';
         a.Department_AER_4__c = 'GI';
         a.Department_AER_5__c = 'GI';
         a.Department_AER_6__c = 'SPD';
          a.Disposable_Irrigation_Tubing__c =
         a.Disposable_Valves__c = 'Defendo';
         a.EGD_Volume_Yearly__c = 26;
         a.ERCP_Volume_Yearly__c = 26;
         a.EUS_Volume_Yearly__c= 27;
         a.QTY_of_AER_in_Dept_1__c= 78 ;
         a.QTY_of_AER_in_Dept_2__c= 1;
         a.QTY_of_AER_in_Dept_3__c= 1000;
         a.QTY_of_AER_in_Dept_4__c=14;
         a.QTY_of_AER_in_Dept_5__c=8;
 
        
        Test.startTest();
       Update a;
        Test.stopTest();
       
        PageReference ref = Page.US_MEDICAL_SALES_Mandatory;
        test.setCurrentPage(ref); 
            }
}
I have this Test Class code and I am not sure what I am doing wrong to get the 2 errors.

isTest
private class EmailServiceExampleTest
{
    static testMethod void testUnsubscribe() 
    {
       // Create a new email and envelope object.    
       
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
    
       // Create Test record.
       Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
       insert cont ;
       
       // Test with the subject that matches the unsubscribe statement.
       email.subject = 'Test Contact Email';
       email.plainTextBody = 'Test Contact Email';

       env.fromAddress = 'test@test.com';
       EmailServiceExample obj= new EmailServiceExample();
       obj.handleInboundEmail(email, env );



I am getting these 2 errors:
Line 20 - Invalid Type: EmailServiceExample
Line 21 - Variable does not exist: obj
 
I am not sure what I am doing wrong in creating this Test Class.  It creates the row correctly but my concern is that I am hardcoding a few of the IDs in the Test Class:

Apex Code:
public with sharing class BpQuotaQtr {

    
private ApexPages.StandardController c;


public List <Quota__c> quotas {get;set;}
public List <Business_Plan__c> bp {get;set;}
public List <Period> period {get;set;}
    
Integer FiscalYearStartMonth = 
[select FiscalYearStartMonth from Organization where id=:Userinfo.getOrganizationId()].FiscalYearStartMonth;

       
String TodaysDate = date.today().format();
     



       // Get information about the Quota being worked on
       // Needs to be based on Business Plan per Person 
       // Need to get the correct FY and Correct Quarter based on todays date.    
       // 
public BpQuotaQtr(ApexPages.StandardController controller) {
    
String strFY = '';
Id bpid1;
  
    business_plan__c bp = (business_plan__c)controller.getRecord();
    
    List <Period> Periods = [Select p.Number From Period p Where (p.StartDate <= TODAY AND p.EndDate >= TODAY) and p.type = 'Quarter' Limit 1];
    List <business_plan__c> bpid = [Select id From business_plan__c bp  where (bp.Start_Date__c <= TODAY AND bp.End_Date__c >= TODAY) LIMIT 1];
                                              

    
    
if(!Periods.isEmpty())
{
/* you have applied LIMIT 1 which means only one record will be retrieved */
strFY = String.valueOf(Periods[0].Number);
bpid1 = bpid[0].id;
}
                                              

    system.debug('*****bpid1*******'+bpid1);
    system.debug('*******strFY *****'+strFY);
    
    quotas = [SELECT  Actual_Sales__c, Actual_vs_Quota__c, Annual_Actual_Sales__c, Annual_Quota__c, Label_Actual_Sales__c, Label_Sales_Won__c,
                          Annual_Targeted_New_Bus_Sale__c, Business_Plan__c, Fiscal_Period2__c,
                               Quota__c, Sales_Categories__c, Sales_Category_Name__c,  Sales_Needed_to_Hit_Quota2__c,Sales_Product_Category__c,
                               Sales_Won__c,Target_vs_Quota__c,Targeted_New_Business_Sales__c
                               FROM Quota__c WHERE ((Start_Date__c = THIS_FISCAL_QUARTER AND End_Date__c = THIS_FISCAL_QUARTER) AND
                                                    Period__c = True AND
                                                   business_Plan__c =:bp.id
                                                   ) 
              ORDER BY Sales_Category_Name__c  ];      
                              
    }


Visualforce Code:
<apex:page standardController="Business_Plan__c" extensions="BpQuotaQtr"  tabStyle="Quota__c">




 <apex:form > 


 <apex:pageBlock title="Current Quarterly Breakout">
  
    
  <style>
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#0000cc;
            }
            body .bPageBlock .pbBody .grey .pbSubheader{
                background-color:#c0c0c0;
            }
            body .bPageBlock .pbBody .grey .pbSubheader h3{
                color:#000;
            }
 </style>


      
      
      <apex:outputPanel styleClass="blue" layout="block">
       <apex:pageBlockSection title="Sales Categories Sales and Quarterly Breakout">  
            </apex:pageBlockSection>
       </apex:outputPanel>
      
      
        <apex:pageBlockTable value="{!quotas}" var="q" >
           <apex:column headerClass="headerStyle"/>
            
              <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Sales_Category_Name__c.Label}" value="{!q.Sales_Category_Name__c }" >  </apex:column>
              <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Quota__c.Label}" value="{!q.Quota__c }" > </apex:column>
              <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Fiscal_Period2__c.Label}" value="{!q.Fiscal_Period2__c }"  > </apex:column>
            
            
              <apex:variable value="{!q.Label_Actual_Sales__c}" var="h1"/>
              <apex:column headerValue="{!h1}" value="{!q.Actual_Sales__c}" >
              </apex:column>
            
            
              
                <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Actual_vs_Quota__c.Label}" value="{!q.Actual_vs_Quota__c}" 
                           style="{!If((q.Actual_vs_Quota__c)< 85,'font-size:15px; font-weight:bold;color:red',
                                  If((q.Actual_vs_Quota__c)> 100,'font-size:15px; font-weight:bold;color:green ','color:black')) }" > </apex:column>
               

              <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Sales_Needed_to_Hit_Quota2__c.Label}" value="{!q.Sales_Needed_to_Hit_Quota2__c}"  > </apex:column>
                           
                     <apex:variable value="{!q.Label_Sales_Won__c}" var="h2"/>
              <apex:column headerValue="{!h2}" value="{!q.Sales_Won__c}" >
              </apex:column>
            
            
              <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Targeted_New_Business_Sales__c.Label}" value="{!q.Targeted_New_Business_Sales__c }" >           </apex:column>
       
       
             <apex:column headerValue="{!$ObjectType.Quota__c.Fields.Target_vs_Quota__c.Label}" value="{!q.Target_vs_Quota__c}" 
                           style="{!If((q.Target_vs_Quota__c)< 85,'font-size:15px; font-weight:bold;color:red',
                                  If((q.Target_vs_Quota__c)> 100,'font-size:15px; font-weight:bold;color:green ','color:black')) }" > </apex:column>    

       
            
       </apex:pageBlockTable>

   
 
  </apex:pageBlock>
  </apex:form>  
</apex:page>

Test Class: 
@isTest
private class BpQuotaQtrTest {

private static final Id id = Schema.SObjectType.quota__c.getRecordTypeInfosByName().get('US Endo Sales').getRecordTypeId();
private static final Id bpcid = Schema.SObjectType.business_plan__c.getRecordTypeInfosByName().get('Capital').getRecordTypeId();
private static final Id bppid = Schema.SObjectType.business_plan__c.getRecordTypeInfosByName().get('Procedural').getRecordTypeId();
 
    
    
    
    @isTest static void BpQuotaQtrTest() {
         


      Quota__c qta = new Quota__c();
       qta.Actual_Sales__c = 10000;
     qta.quota__c  = 1000000;
     qta.Annual_Actual_Sales__c = 300000;
     qta.Annual_Quota__c = 10000000;
     qta.Annual_Targeted_New_Bus_Sale__c = 300000; 
     qta.Business_Plan__c = 'a3I0P000000Cw8a'; 
     qta.Fiscal_Period2__c = 'Q2';
     qta.Quota__c = 250000;
     qta.Sales_Categories__c = 'a5f0P000000Pfr6'; 
     qta.Sales_Won__c = 2500;
     qta.Targeted_New_Business_Sales__c = 3400;

      
      insert qta;


        
        Test.setCurrentPage(Page.BpQuotaQtr);


        

        }

    }
 trigger QueueTrigger on Sales_Product_Category__c (after insert, after update, after delete) {
   
    CustomTriggerSwitch__c ct = CustomTriggerSwitch__c.getValues('salescategory');
    
    if(ct == null || ct.Active__c || Sales_Product_Category__c.business_plan__c <> null || 
      Sales_Product_Category__c.ID <> null){ 
           
     
        List<Sales_Product_Category__c> salescategory = (Trigger.isDelete ? Trigger.old : Trigger.new);

        System.enqueueJob(new QuotaProductQueueable(salescategory,Trigger.oldMap));
}

}


The error is bolded :  Constructor not defined: [QuotaProductQueueable].<Constructor>(List<Sales_Product_Category__c>, Map<Id,Sales_Product_Category__c>)

What am I missing? 

 
I want the column heading to say "Invoiced" for one group of people and "Actual Sales" for another group of people.  

            
                    <apex:column headerValue="Actual Sales" rendered={!if(!q.IsProcedural__c,true,false)}">
                        <apex:outputText value="{!q.Annual_Actual_Sales__c}" style="width:70px" />
                    </apex:column>

Now this is not rendering anything for anyone.  What am I doing wrong?
I am getting 2 Errors that I am unclear how to fix them.  Any guidance would be great.  

Illegal assignment from List<OpportunityLineItem> to List<Quota__c> Line 11
Constructor not defined: [QuotaProductQueueable].<Constructor>(List<Quota__c>, Map<Id,OpportunityLineItem>) Line 15

trigger OpportunityProductTrigger on OpportunityLineItem (after insert, after update, after delete) {
    CustomTriggerSwitch__c cts = CustomTriggerSwitch__c.getValues('OpportunityProduct');
    CustomTriggerSwitch__c ct = CustomTriggerSwitch__c.getValues('Quota__c');
    
    if(cts == null || 
       cts.Active__c || 
       opportunityLineItem.Opportunity.business_plan__c <> null || 
       opportunityLineItem.Quota__c.ID <> null){ 
           
        List<OpportunityLineItem> olis = (Trigger.isDelete ? Trigger.old : Trigger.new);
        List<Quota__c> qta = (Trigger.isDelete ? Trigger.old : Trigger.new);
        
        
       // System.enqueueJob(new OpportunityProductQueueable(olis,Trigger.oldMap));
        System.enqueueJob(new QuotaProductQueueable(qta,Trigger.oldMap));
    }
}
**Still Learning**
I am trying to create the Apex Controller that will then be used by the Visualforce page for layouts.  I only want to show the Current Fiscal Period based on Todays date on the Visualforce page.  

Period_FY__c is just a formula field that is a String:  Below is the code for the formula field.
CASE( 
Text(Month(TODAY() )) , 
"1","2", 
"2","3", 
"3","3", 
"4","3", 
"5","4", 
"6","4", 
"7","4", 
"8","1", 
"9","1", 
"10","1", 
"11","2", 
"12","2", 
"" 
)

The code where I am having an error.  If there is a different way this would be written better I am open. (learning)

public with sharing class QuotaRelatedListqtr {

public List <Quota__c> quotas {get;set;}
public List <Business_Plan__c> bp {get;set;}
public List <Period> period {get;set;}
    
Integer FiscalYearStartMonth = 
[select FiscalYearStartMonth from Organization where id=:Userinfo.getOrganizationId()].FiscalYearStartMonth;

String TodaysDate = date.today().format();
     
Public List <Period> Periods = [Select p.Number From Period p 
         Where (p.StartDate <= TODAY AND p.EndDate >= TODAY) and p.type = 'Quarter' Limit 1];


       // Get information about the Quota being worked on
       // Needs to be based on Business Plan per Person 
       // Need to get the correct FY and Correct Quarter based on todays date.    
       // 
public QuotaRelatedListqtr(ApexPages.StandardController controller) {
 quotas = [SELECT Actual_Sales__c, Actual_vs_Quota__c, Annual_Actual_Sales__c, Annual_Quota__c, 
                           Annual_Targeted_New_Business_Sales__c, Business_Plan__c, Fiscal_Period2__c,
                               Quota__c, Sales_Categories__c, Sales_Category_Name__c,  Sales_Needed_to_Hit_Quota__c,Sales_Product_Category__c,
                               Sales_Won__c, Targeted_New_Business__c,Target_vs_Quota__c,Targeted_New_Business_Sales__c
                               FROM Quota__c
                              WHERE Period_FY__c IN :Periods];    
                             
    }
              
}


Here is the Error Message:  Invalid bind expression type of Period for column of type String
I have bolded the line where it is saying the error is.

 
When I have made a field not editable within Visualforce.  I have a process builder that needs to update to update the field.  

When the field is able to be updated then the Process Builder works with no issues.  
I have a custom button that SELECTS a Product for the Opportunity Lines.   This works great

Addition that is needed:
When the product is SELECTED and the Number of Years = 1 or greater  ---  I need it to populate a value  that is on the Opportunity Line Number that equals the number of years.  I am not sure the best way to get this to work.  If the Number of Years = 0 I do not want to change the dollar value for them.  


Do I need to use a Flow or Process builder?
 
I am not 100% sure what is wrong with this Test Script:

@isTest
    public class EndoraDocumentAttachment { 

        //Method
        static testMethod void InsertAttachment() {

        Opportunity b = new opportunity();
        b.RecordType.developername = 'Capital';   
        b.name = 'TEST';
        b.Quote_Contact__c = '0033B000007Rz8X';   
        b.StageName = 'Attention';
        b.CloseDate = (System.Today().addDays(1));
        b.Account_Dept__c = 'GI/Endoscopy';
        insert b;

        Attachment attach = new Attachment();

        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
        attach.body=bodyBlob;
        attach.parentId=b.id;
        insert attach;

        List<Attachment> attachments=[select id, name from Attachment where parent.id=:b.id];
        System.assertEquals(1, attachments.size());

         attach = [SELECT Id, name from Attachment where parent.id=:b.id];

            delete attach;  

            b.Attachment__c = False;
            update b;      


    }
    }


Errors: System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.EndoraDocumentAttachment.InsertAttachment: line 8, column 1
I need some help with making this a smaller so it will fit in the formula field.

If(
            Unit_Price_Upside__c = 0, (

TotalPrice/
IF(
     ISPICKVAL(PricebookEntry.Product2.Family,"Service Contracts"),
     Number_of_Years_SC__c,
     IF(
         AND(
                Opportunity.RecordType.DeveloperName="Procedural",
                (PricebookEntry.Product2.Marketing_Division__c="MR" ||
                 PricebookEntry.Product2.Marketing_Division__c="BMG")
                ),
         Value(Text(Opportunity.Number_of_Years__c)),
         1))),
((Quantity *  Unit_Price_Upside__c)/
IF(
     ISPICKVAL(PricebookEntry.Product2.Family,"Service Contracts"),
     Number_of_Years_SC__c,
     IF(
         AND(
                Opportunity.RecordType.DeveloperName="Procedural",
                (PricebookEntry.Product2.Marketing_Division__c="MR" ||
                 PricebookEntry.Product2.Marketing_Division__c="BMG")
                ),
         Value(Text(Opportunity.Number_of_Years__c)),
         1))
         
    
)
)
A new developer and I am getting this error.  I have highlighted where the error is I cannot figure out why I am getting it.
The error is: Only top-level class variables can be declared static


 
        if(mapQuoteErrorList.get(thisQuote.Id) != null){ //|| thisQuote.Generate_Quote_as_Final__c == false){
          thisQuote.Status_Message__c = mapQuoteErrorList.get(thisQuote.Id);
        thisQuote.Generate_Quote_as_Final__c = false;
        thisQuote.Quote_Stage__c = 'DRAFT     DRAFT     DRAFT     DRAFT     DRAFT     DRAFT';
        thisQuote.Status = 'Draft'; 
        thisQuote.Date_and_Time_of_Final__c = NULL ;    
        } else {
        //if(thisQuote.Generate_Quote_as_Final__c == true) {
          thisQuote.Status_Message__c = 'Quote contains no pricing errors and requires no additional approvals.';
          thisQuote.Quote_Stage__c = 'FINAL';
          thisQuote.Status = 'Final';
          thisQuote.Generate_Quote_as_Final__c = true;
          thisQuote.Date_and_Time_of_Final__c = System.now() ;
        }    
      }
    }
   
  private static void CheckMinimumPrices(map<Id,QuoteLineItem> mapQLI,
                                            map<Id, String> mapQuoteApprovalLevel,
                                               map<Id, String> mapQuoteErrorList,
                                               map<Id, boolean> mapQuoteIsCapital){
    for(QuoteLineItem thisQL : mapQLI.values()){
        if(thisQL.UnitPrice > 0){ //|| mapQuoteIsCapital.get(thisQL.QuoteId) == null){ //if the line item is greater than zero, or there is no capital on the account
            boolean alreadySetMin = false;                                           //because if there is no capital, the zero should be treated as a value below min
            if(thisQL.PricebookEntry.UseStandardPrice
                || thisQL.PricebookEntry.Pricebook2.Name.ContainsIgnoreCase('Standard')){
                if(thisQL.PricebookEntry.RD_Minimum_Price__c != null){
                  if(thisQL.UnitPrice < thisQL.PricebookEntry.RD_Minimum_Price__c
                     && (thisQL.PricebookEntry.RD_Minimum_Price__c
                        != thisQL.PricebookEntry.Minimum_Price__c)){ //less than DOS Min and Mins are not Equal
                    if(mapQuoteApprovalLevel.get(thisQL.QuoteId) == 'Director'
                             || mapQuoteApprovalLevel.get(thisQL.QuoteId) == null){
                      if(!(mapQuoteErrorList.containsKey(thisQL.QuoteId))){        
                        mapQuoteErrorList.put(thisQL.QuoteId, 'The price quoted for ' +
                          thisQL.PricebookEntry.Product2.ProductCode
                          + ' is below the minimum price and requires Area VP approval.' + '<br/>');
                          alreadySetMin = true; {
                if(thisQL.PricebookEntry.VP_Minimum_Price__c != null){
                  if(thisQL.UnitPrice < thisQL.PricebookEntry.VP_Minimum_Price__c
                     && (thisQL.PricebookEntry.VP_Minimum_Price__c
                        != thisQL.PricebookEntry.RD_Minimum_Price__c)){ //less than RD Min and VP are not Equal
                    if(mapQuoteApprovalLevel.get(thisQL.QuoteId) == 'VP'
                             || mapQuoteApprovalLevel.get(thisQL.QuoteId) == null){
                      if(!(mapQuoteErrorList.containsKey(thisQL.QuoteId))){        
                        mapQuoteErrorList.put(thisQL.QuoteId, 'The price quoted for ' +
                          thisQL.PricebookEntry.Product2.ProductCode
                          + ' is below the minimum price and requires Marketing Director approval.' + '<br/>');
                          alreadySetMin = true;
                      } else {
                  mapQuoteErrorList.put(thisQL.QuoteId, mapQuoteErrorList.get(thisQL.QuoteId)
                  + 'The price quoted for ' +
                    thisQL.PricebookEntry.Product2.ProductCode
                    + ' is below the minimum price and requires Marketing Director approval.' + '<br/>');          
                    alreadySetMin = true;              
                      }
                    }               
                  }   
                }
                if(thisQL.PricebookEntry.Minimum_Price__c != null){
                  if(thisQL.UnitPrice < thisQL.PricebookEntry.Minimum_Price__c  //less than min
                                                                     && !alreadySetMin){
                    if(mapQuoteApprovalLevel.get(thisQL.QuoteId) == null){      
                      if(!(mapQuoteErrorList.containsKey(thisQL.QuoteId))){
                        if(!alreadySetMin){                        
                          mapQuoteErrorList.put(thisQL.QuoteId, 'The price quoted for ' +
                            thisQL.PricebookEntry.Product2.ProductCode
                            + ' is below the minimum price and requires DOS approval.' + '<br/>');
                        } 
                      } else {
                        if(!alreadySetMin){
                          mapQuoteErrorList.put(thisQL.QuoteId, mapQuoteErrorList.get(thisQL.QuoteId)
                              + 'The price quoted for ' +
                      thisQL.PricebookEntry.Product2.ProductCode
                      + ' is below the minimum price and requires DOS approval.' + '<br/>');
                        }   
                     }
             }
          } else { //not a standard price
            if(thisQL.UnitPrice < thisQL.PricebookEntry.UnitPrice
               && (mapQuoteApprovalLevel.get(thisQL.QuoteId) == null
               || mapQuoteApprovalLevel.get(thisQL.QuoteId) == 'Director')){
              if(!(mapQuoteErrorList.containsKey(thisQL.QuoteId))){     
                  mapQuoteErrorList.put(thisQL.QuoteId, 'The price quoted for ' +
                      thisQL.PricebookEntry.Product2.ProductCode
                      + ' is invalid. Discounts to GPO Prices require Area VP approval.' + '<br/>');
                      //set quote error variable to true
              } else {
              mapQuoteErrorList.put(thisQL.QuoteId, mapQuoteErrorList.get(thisQL.QuoteId)
                    + 'The price quoted for ' +
                    thisQL.PricebookEntry.Product2.ProductCode
                    + ' is invalid. Discounts to GPO Prices require Marketing Director approval.' + '<br/>');
                    //set quote error variable to true             
                    }      
                }
            }               
        }
                          }
  private static map<Id, String> QuoteApprovalLevel(set<Id> setQuoteIds){
    map<Id, String> mapQuoteApprovalLevel = new map<Id, String>();
    map<String, DateTime> mapQuoteLineItemLastTouched
      = QuoteLineItemLastTouched(setQuoteIds);
    for(ProcessInstanceStep thisPI : [SELECT StepStatus,
                                         Actor.UserRole.Name,
                                         ProcessInstance.Status,
                                         ProcessInstance.TargetObjectId,
                                         ProcessInstance.LastModifiedDate
                                   FROM ProcessInstanceStep
                                          WHERE ProcessInstance.TargetObjectId
                                          IN :setQuoteIds
                                          AND ProcessInstance.isDeleted = false
                                          AND ProcessInstance.Status = 'Approved'
                                          AND StepStatus = 'Approved'
                                          ORDER BY
                                          Actor.UserRole.Name ASC,
                                          ProcessInstance.TargetObjectId ASC,
                                                   ProcessInstance.LastModifiedDate DESC]){ 
      if(thisPI.Actor.UserRole.Name.contains('Director')){
        if(thisPI.ProcessInstance.LastModifiedDate >
            mapQuoteLineItemLastTouched.get(thisPI.ProcessInstance.TargetObjectId)){                                                    
          mapQuoteApprovalLevel.put(thisPI.ProcessInstance.TargetObjectId,'Director');
        } 
      }  
      if(thisPI.Actor.UserRole.Name.contains('VP')){
        if(thisPI.ProcessInstance.LastModifiedDate >
            mapQuoteLineItemLastTouched.get(thisPI.ProcessInstance.TargetObjectId)){                                                      
          mapQuoteApprovalLevel.put(thisPI.ProcessInstance.TargetObjectId,'VP');
        } 
      }
      if(thisPI.Actor.UserRole.Name.contains('SVP')){
        if(thisPI.ProcessInstance.LastModifiedDate >
            mapQuoteLineItemLastTouched.get(thisPI.ProcessInstance.TargetObjectId)){                                                      
          mapQuoteApprovalLevel.put(thisPI.ProcessInstance.TargetObjectId,'SVP');
        } 
      }      
                   
    return mapQuoteApprovalLevel;      
  }
  }
  private static map<String, DateTime> QuoteLineItemLastTouched(set<Id> setQuoteIds){
    map<String, DateTime> mapQuoteLineItemLastTouched
      = new map<String, DateTime>();
   
    for(AggregateResult thisAR : [SELECT QuoteId, MAX(LastModifiedDate) MaxDate FROM QuoteLineItem
                                  WHERE QuoteId IN :setQuoteIds
                                  GROUP BY QuoteId]){
      mapQuoteLineItemLastTouched.put(string.valueOf(thisAR.get('QuoteId')),
                                      DateTime.valueOf(thisAR.get('MaxDate')));
    }
    return mapQuoteLineItemLastTouched;
  }
}
 
I have a field on the OpportunityLineItem.To_Business_plan__c that I want when the product is selected it automatically defaults to checked on the Product Selector.  I have highlighted the piece of code not working.  Any help would be much appreciated.  

APEX CLASS:
public with sharing class opportunityProductEntryExtension {


    public Opportunity theOpp {get;set;}
    public Opportunitylineitem opli {get;set;}
    public String searchString {get;set;}
    public List<OpportunityLineItemWrapper> shoppingCart {get;set;}
    public List<PricebookEntry> availableProducts {get;set;}
    public Pricebook2 theBook {get;set;}

    public String toSelect {get; set;}
    public String toUnselect {get; set;}
    public Decimal Total {get;set;}

    public Boolean overLimit {get;set;}
    public Boolean multipleCurrencies {get; set;}

    
    public with sharing class controller {
    public list < opportunitylineitem> objb = [select to_business_plan__c from opportunitylineitem];
    public list <opportunitylineitem> getRecords() {
        if(objb <> null){
            for(opportunitylineitem  opli : objb){
                opli.to_business_plan__c = true;
            }
        }
        return objb;
    }
}

    
 
VisualForce:

                       <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.To_Business_Plan__c.Label}">
                                 <apex:inputCheckbox value="{!s.oli.To_Business_Plan__c}" id="objb"/>
                       </apex:column>

The page renders but the checkbox is not defaulting to checked.

 
Hello All,

For some reason piece of my code is not being read when creating a Quote.  If the Quote Line Item has a Product Code = BMT-1003 I need an error message to appear.   I have bolded where I am thinking I wrote the code wrong.  


public with sharing class QuoteUtility {
  
  public static void AddExtraVerbiage(list<Quote> lstQuotes){
    map<Id, string> mapQuoteInstallReq = new map<Id, String>();
    list<GPOTerms__c> lstGPOTerms = GPOTerms__c.getall().values();
    map<String, Product_Installation_Requirement__c> mapInstallReq 
      = new Map<String, Product_Installation_Requirement__c>();
    list<Product_Installation_Requirement__c> lstInstallReq 
      = [SELECT Name, Installation_Note__c 
         FROM Product_Installation_Requirement__c];
    for(Product_Installation_Requirement__c p : lstInstallReq){ 
        mapInstallReq.put(p.Name, p); 
    }
    set<Id> setQuoteIds = new set<Id>();
    for(Quote thisQuote : lstQuotes){
      setQuoteIds.add(thisQuote.Id);
    } 
    
    

    
    
    map<Id, QuoteLineItem> mapQLIs = new map<Id, QuoteLineItem>([SELECT Id, QuoteId, 
                                  PricebookEntry.Product2Id,
                                  PricebookEntry.Product2.ProductCode,
                                  PricebookEntry.Pricebook2.Name
                                FROM QuoteLineItem
                                WHERE QuoteId IN :setQuoteIds]);
    for(Quote thisQuote : lstQuotes){                            
    String strInstallReqs = '';                               
        for(QuoteLineItem thisQI : mapQLIs.values()){ 
            if (thisQI.QuoteId == thisQuote.Id){
                //install req's
            if(mapInstallReq.get(thisQI.PricebookEntry.Product2.ProductCode) != null){
                if(!mapQuoteInstallReq.containsKey(thisQuote.Id)){
              mapQuoteInstallReq.put(thisQuote.Id, 
                mapInstallReq.get(thisQI.PricebookEntry.Product2.ProductCode).Installation_Note__c + '\n');
                } else {
                    mapQuoteInstallReq.put(thisQuote.Id, 
                mapQuoteInstallReq.get(thisQuote.Id) 
                + mapInstallReq.get(thisQI.PricebookEntry.Product2.ProductCode).Installation_Note__c + '\n');
                }                   
            }                       
        }                             
        }
        if(mapQuoteInstallReq.get(thisQuote.Id) != null){
          thisQuote.Product_Specific_Instructions__c 
            = mapQuoteInstallReq.get(thisQuote.Id);
        }
        //GPO Terms
        for(GPOTerms__c thisGPOTerm : lstGPOTerms) {
            if(thisQuote.GPO_Affiliation__c != null) {
            if(thisQuote.GPO_Affiliation__c.contains(thisGPOTerm.Name)) {
               thisQuote.Customer_Tier__c = thisGPOTerm.Terms__c;
            }
            }
      }
    } 
  }
  
    public static void ValidateLineItems(list<Quote> lstQuotes){
        set<Id> setQuoteIds = new set<Id>();
    map<Id, boolean> mapQuoteIsCapital = new map<Id, boolean>();
    map<Id, integer> mapQuoteCapitalCount = new map<Id, integer>();
    map<Id, boolean> mapQuoteHasZeroDollar = new map<Id, boolean>();
    map<Id, decimal> mapQuoteZeroDollarTotal = new map<Id, decimal>();
    map<Id, decimal> mapQuoteTradeInValue = new map<Id, decimal>();
    map<Id, String>  mapQuoteBIOMed = new map<Id, String>();
    map<Id, String> mapQuoteErrorList = new map<Id, String>();
    map<Id, String> mapQuoteApprovalLevel = new map<Id, String>();
    map<Id, map<string, decimal>> mapQuoteZeroDollarExceptions 
      = new map<Id, map<string,decimal>>();
    map<Id, map<string, decimal>> mapQuoteExceptionsUsed 
      = new map<Id, map<string,decimal>>();
       
    for(Quote thisQuote : lstQuotes){
      setQuoteIds.add(thisQuote.Id);
      thisQuote.Status_Message__c = null;
      mapQuoteCapitalCount.put(thisQuote.Id, 0);
      mapQuoteTradeInValue.put(thisQuote.Id, 0);
      mapQuoteZeroDollarExceptions.put(thisQuote.Id, new map<string, decimal>());
      mapQuoteExceptionsUsed.put(thisQuote.Id, new map<string, decimal>());
    }
    
    map<Id, QuoteLineItem> mapQLIs = new map<Id, QuoteLineItem>([SELECT Id, QuoteId, 
                                  PricebookEntry.Product2Id,
                                  PricebookEntry.Product2.ProductCode,
                                  PricebookEntry.Pricebook2.IsStandard,
                                  PricebookEntry.Product_Exceptions__c,
                                  PricebookEntry.UseStandardPrice,
                                  PricebookEntry.UnitPrice,
                                  PricebookEntry.Pricebook2.Id,
                                  PricebookEntry.Pricebook2Id,
                                  PricebookEntry.Minimum_Price__c, 
                                  PricebookEntry.RD_Minimum_Price__c,
                                  PricebookEntry.Product2.Family,
                                  PricebookEntry.Product2.Installed_Product__c,
                                  PricebookEntry.Pricebook2.Name,
                                  UnitPrice,
                                  Quantity
                                FROM QuoteLineItem
                                WHERE QuoteId IN :setQuoteIds
                                ORDER BY PricebookEntry.UnitPrice DESC]);
     
    for(QuoteLineItem thisQL : mapQLIs.values()){
        system.debug(logginglevel.ERROR, 'thisQL: ' + thisQL);
              if(thisQL.PricebookEntry.Product2.Family != null){
              //if(thisQL.PricebookEntry.Product2.Family.Contains('Reprocessor')
              // || thisQL.PricebookEntry.Product2.Installed_Product__c == true){
              mapQuoteIsCapital.put(thisQL.QuoteId, true);
              if(thisQL.PricebookEntry.Product_Exceptions__c != null){
                for(string thisExceptionLevel : thisQL.PricebookEntry.Product_Exceptions__c.split('\r\n')){
              if(!(mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).containsKey(thisExceptionLevel.split('\\|')[0]))){
                        mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).put(thisExceptionLevel.split('\\|')[0], decimal.valueof(thisExceptionLevel.split('\\|')[1])*thisQL.Quantity);
                  } else {
                      mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).put(thisExceptionLevel.split('\\|')[0], 
                            mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).get(thisExceptionLevel.split('\\|')[0]) 
                              + decimal.valueof(thisExceptionLevel.split('\\|')[1])*thisQL.Quantity);
                  }
                }
              }
              system.debug(logginglevel.ERROR, 'ZeroDollarExceptions: ' + mapQuoteZeroDollarExceptions);
             //}
            }
        if(thisQL.PricebookEntry.Product2.ProductCode == 'Upgrade Discount'){
            mapQuoteTradeInvalue.put(thisQL.QuoteId, 
          mapQuoteTradeInvalue.get(thisQL.QuoteId) + thisQL.UnitPrice);
        }
         if(thisQL.PricebookEntry.Product2.ProductCode == 'BMT-1003'){
            mapQuoteBIOMed.put(thisQL.QuoteId, 
          mapQuoteBIOMed.get(thisQL.QuoteId) + thisQL.UnitPrice);
        }
    }
    
    system.debug(logginglevel.ERROR, 'Starting Second Loop');
    for(QuoteLineItem thisQL : mapQLIs.values()){ 
        if(thisQL.UnitPrice == 0){ //for each zero dollar line item
            boolean isValidException = false;
            mapQuoteHasZeroDollar.put(thisQL.QuoteId, true);
            for(string thisException : mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).keySet()){  //go through all of the exceptions
                system.debug(logginglevel.ERROR, 'Exceptions for this Quote: ' + mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).keySet());
                system.debug(logginglevel.ERROR, 'This Exception: ' + thisException);
              if(thisException.contains(thisQL.PricebookEntry.Product2.ProductCode)){
                system.debug(logginglevel.ERROR, 'Exception List Contains this part');
                if(!(mapQuoteExceptionsUsed.get(thisQL.QuoteId).containsKey(thisException))){  //if there isn't an exc used for this
              mapQuoteExceptionsUsed.get(thisQL.QuoteId).put(thisException, thisQL.Quantity); //put one
            } else {
                system.debug(logginglevel.ERROR, 'Exception List doesnt contain this part');
              mapQuoteExceptionsUsed.get(thisQL.QuoteId).put(thisException, //otherwise get it and add to it
                mapQuoteExceptionsUsed.get(thisQL.QuoteId).get(thisException) + thisQL.Quantity);
            }
            if(mapQuoteExceptionsUsed.get(thisQL.QuoteId).get(thisException) != null){ 
              system.debug(logginglevel.ERROR, 'Used Exceptions: ' + mapQuoteExceptionsUsed.get(thisQL.QuoteId).get(thisException));
              system.debug(logginglevel.ERROR, 'Available Exceptions: ' + mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).get(thisException));
              if(mapQuoteExceptionsUsed.get(thisQL.QuoteId).get(thisException) <=   //ths is coming back as even
                mapQuoteZeroDollarExceptions.get(thisQL.QuoteId).get(thisException)){ 
                isValidException = true;
                break;
              } else {
                isValidException = false;
              }
            } 
            
             System.debug(logginglevel.ERROR,'BMT-1003 Product');
               system.debug(logginglevel.ERROR, 'thisQL: ' + thisQL);
               
              if(thisQL.Product_Code__c == ('BMT-1003')  
              && (mapQuoteApprovalLevel.get(thisQL.QuoteId) == null
               || mapQuoteApprovalLevel.get(thisQL.QuoteId) == 'Director'))
              {
              if(!(mapQuoteErrorList.containsKey(thisQL.QuoteId))){      
                  mapQuoteErrorList.put(thisQL.QuoteId, 'The Bio-Med Training quoted for ' + 
                      thisQL.PricebookEntry.Product2.ProductCode 
                      + 'needs to have Service Director and DOS Approval.' + '</br>'); 
                     
              } else
              {
              mapQuoteErrorList.put(thisQL.QuoteId, mapQuoteErrorList.get(thisQL.QuoteId) 
                    + 'The Bio-Med Training quoted for' + 
                    thisQL.PricebookEntry.Product2.ProductCode 
                    + ' needs to have Service Director and DOS Approval.' + '</br>');         

              } 
            }
       
Error: Compile Error: Illegal variable declaration: oli.Annual_Revenue_Upside__c at line 109 column 70

Here is the line of code: (it is the first line of code)  Annual_Revenue Upside is a Number .  I am not sure what the Illegal Variable Declaration is. do I need to start over and make the field a Currency?

    private Decimal add(Decimal rollup, Decimal UnitPrice, Decimal oli.Annual_Revenue_Upside__c)
    {
        UnitPrice = (oli.Annual_Revenue_Upside__c != null) ? oli.Annual_Revenue_Upside__c : UnitPrice;
        return rollup + ((UnitPrice == null) ? 0 : UnitPrice);
    }
 
I am trying to be a Recall Button on the Quote Page:  I am receiving the error: A problem with the OnClick JavaScript for this button or link was encountered:  Unexpected Identifier.

Apex Class:
global class approvalRecall
{
    webservice static void recallApproval(Id recId)    
    {        
        List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
        req.setAction('Removed');        
        req.setWorkitemId(piwi.get(0).Id);
   
        Approval.process(req,false);
    }
}




{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 


var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 

sforce.apex.execute("approvalRecall","recallApproval",{ID:"{!Quote.Id}"}); 
alert("Approval has been recalled"); 
window.open('/{!Quote.Id}'); 

else 

alert("Recall Cancelled"); 
}{!Quote.Id}
I am getting a couple of errors with the Controller which then gives me an error in Visualforce page.  

I am trying to let the user add multiple rows of information from one screen.  I am trying to allow the user to hit Add in the table so that we can get more information.   I will need another table with the same capability to be able to add another row.  Most of the time we won't need to add a row but I would rather do it right the first time.   I am just learning how to do this so any guidance would be great.



Apex Class
public class MultiAdd
{
    //will hold the Endora records to be saved
    public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();

    //list of the inner class

    public List<innerClass> lstInner

    {   get;set;    }

    //will indicate the row to be deleted

    public String selectedRowIndex
    {get;set;} 
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    //{get;set;}

    ////save the records by adding the elements in the inner class list to lstinner,return to the same page

    public PageReference Save()

    {
        PageReference pr = new PageReference('/apex/MultiAdd');
        for(Integer j = 0;j<lstEndoras.size();j++)
        {
            lstInner.add(lstEndora[j].endora__c);   (error)
        }
        insert lstInner;
        pr.setRedirect(True);
        return pr;

    }

    //add one more row

    public void Add()

    {  

        count = count+1;

        addMore();     

    }

    /*Begin addMore*/

    public void addMore()

    {

        //call to the iner class constructor

        innerClass objInnerClass = new innerClass(count);

        //add the record to the inner class list
        lstInner.add(objInnerClass);   
        system.debug('lstInner---->'+lstInner);           

    }/* end addMore*/

    /* begin delete */

    public void Del()

    {

        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;

    }/*End del*/

    /*Constructor*/

    public MultiAdd(ApexPages.StandardController ctlr)

    {

        lstInner = new List<innerClass>();

        addMore();

        selectedRowIndex = '0';

    }/*End Constructor*/

    /*Endora Class*/

    public class innerClass

    {      

        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */

        public String recCount

        {get;set;}

        public Endora_Information__c endora

        {get;set;}

        /*Inner Class Constructor*/

        public innerClass(Integer intCount)

        {

            recCount = String.valueOf(intCount);       

            /*create a new endora record*/

            endora = new Endora_Information__c();

        }/*End Inner class Constructor*/   

    }
}
    /*End inner Class*/

Error:  Incompatible element type Decimal for collection of MultiAdd.innerClass

Visual Force page  (everything works that is bolded) 
Error: Line 1 Previous load of class failed: MultiAdd: line 28, column 13: Incompatible element type Decimal for collection of MultiAdd.innerClass


<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
    <apex:relatedList list="Endora_Information__c"/>
    <apex:form >
        <style type="text/css">
    .pbTitle {
        white-space: nowrap
             }
        </style>
        <apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
            How many total procedure rooms? &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
            
            <b>PROCEDURE ROOM/QTY</b><p/>
            ENDORA kiosks #45040-73  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
            Workflow Software only (customer provides hardware) #ENDO-777 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
         </apex:pageBlock>
        
         <apex:pageBlock title="Travel Carts">
            How many travel carts will track endoscopes? &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
            <b>TRAVEL CARTS/QTY</b><p/>
            ENDORA kiosks #45040-73  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
            Workflow Software only (customer provides hardware) #ENDO-777 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
         </apex:pageBlock>
        
        
        <apex:pageBlock title="Kiosk Mounts">
            Kiosk mount total by type for procedure rooms:? &nbsp;&nbsp; <p/>
            <b>KIOSK MOUNTS/QTY</b><p/>
            Flush Wall Mount #72233-847  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
            Flush Tilt Wall Mount #72233-849 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
            Arm Wall Mount #72233-848  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
            Floor Stand #72233-850 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
         </apex:pageBlock>

        
        
        
        <apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
        <apex:commandbutton value="Save" action="{!Save}"/>
       

        
        apex:pageblock id="pb1">
        
     
        <apex:repeat value="{!lstInner}" var="e1" id="therepeat">
                <apex:panelGrid columns="5">
                <apex:panelGrid headerClass="Endora">
                    <apex:facet name="header">Del</apex:facet>
                    <apex:commandButton value="X" action="{!Del}" rerender="pb1">
                        <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
                    </apex:commandButton>
                </apex:panelGrid>
                <apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
                    <apex:facet name="header">Department</apex:facet>
                    <apex:inputfield value="{!e1.acct.ShippingCountry}"/>
                </apex:panelGrid>
                    
                <apex:panelGrid >
                    <apex:facet name="header">Floor/Room#</apex:facet>
                    <apex:inputfield value="{!e1.acct.Active__c}"/>
                </apex:panelGrid>
                 
                <apex:panelGrid >
                 <apex:facet name="header">Kiosk Quantity</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
                    
                <apex:panelGrid >
                 <apex:facet name="header">Mount Type</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
                <apex:panelGrid >
                 <apex:facet name="header">Kiosk Quantity</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
            </apex:panelgrid>
        </apex:repeat>
       
      </apex:form> 
</apex:page>
Hello All,

I am trying to make a Visual Force email for our sales team for a list of Accounts that their Service Contracts are expiring soon.  I am sure I am missing something but all I get is the headers no detail.  
<messaging:emailTemplate subject="Service Contracts Expiring" 
                         recipientType="User" 
                         relatedToType="SVMXC__Service_Contract__c">


<messaging:htmlEmailBody >
<html>
    <body>
         <STYLE type="text/css">
               BODY {font-size: 12px; font-face: arial; }
               TH {font-size: 12px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center; } 
               TD  {font-size: 12px; font-face: verdana; } 
               TABLE {border: solid #CCCCCC; border-width: 1; }
               TR {border: solid #CCCCCC; border-width: 1; }
         </STYLE>

  <strong>Below are your accounts that are close to Expired Service Contracts</strong>
          
      
        <table border="0" >
        
        
        <strong>Accounts Expiring Contracts</strong> 
            <tr> 
                <th>Account Name</th><th>Contract Name/Number</th><th>Contract Product Name</th><th>End Date</th><th>Shipping City</th>
            </tr>
            <apex:repeat >
            <tr>
              
                <td>{SVMXC__Company__c}</td>
                <td>{Name}</td>
                <td>{a.Contract_PN__c}</td>
                <td>{a.SVMXC__End_Date__c}</td>
                
            </tr>
            </apex:repeat>
        </table>
        <p />
       



       
 
            
    </body>
</html>
When I do a Preview Template all I get is the nice headers and Subject.  I am not sure how to show the data.  The Process Builder will be All Accounts whoes expiration date is less than 30 days and then this email will be sent to the Reps that own the accounts. 

Thank you for your help in advance.  #learning 
 
**Still Learning**
I am trying to create the Apex Controller that will then be used by the Visualforce page for layouts.  I only want to show the Current Fiscal Period based on Todays date on the Visualforce page.  

Period_FY__c is just a formula field that is a String:  Below is the code for the formula field.
CASE( 
Text(Month(TODAY() )) , 
"1","2", 
"2","3", 
"3","3", 
"4","3", 
"5","4", 
"6","4", 
"7","4", 
"8","1", 
"9","1", 
"10","1", 
"11","2", 
"12","2", 
"" 
)

The code where I am having an error.  If there is a different way this would be written better I am open. (learning)

public with sharing class QuotaRelatedListqtr {

public List <Quota__c> quotas {get;set;}
public List <Business_Plan__c> bp {get;set;}
public List <Period> period {get;set;}
    
Integer FiscalYearStartMonth = 
[select FiscalYearStartMonth from Organization where id=:Userinfo.getOrganizationId()].FiscalYearStartMonth;

String TodaysDate = date.today().format();
     
Public List <Period> Periods = [Select p.Number From Period p 
         Where (p.StartDate <= TODAY AND p.EndDate >= TODAY) and p.type = 'Quarter' Limit 1];


       // Get information about the Quota being worked on
       // Needs to be based on Business Plan per Person 
       // Need to get the correct FY and Correct Quarter based on todays date.    
       // 
public QuotaRelatedListqtr(ApexPages.StandardController controller) {
 quotas = [SELECT Actual_Sales__c, Actual_vs_Quota__c, Annual_Actual_Sales__c, Annual_Quota__c, 
                           Annual_Targeted_New_Business_Sales__c, Business_Plan__c, Fiscal_Period2__c,
                               Quota__c, Sales_Categories__c, Sales_Category_Name__c,  Sales_Needed_to_Hit_Quota__c,Sales_Product_Category__c,
                               Sales_Won__c, Targeted_New_Business__c,Target_vs_Quota__c,Targeted_New_Business_Sales__c
                               FROM Quota__c
                              WHERE Period_FY__c IN :Periods];    
                             
    }
              
}


Here is the Error Message:  Invalid bind expression type of Period for column of type String
I have bolded the line where it is saying the error is.

 
This is our old Page Reference for the Classic: It is creating a new Quote Page and updating certain fields:
PageReference pref =  new PageReference('lightning/0Q0/e?Name=' + EncodingUtil.urlEncode(theOpp.Name,'UTF-8')  + '&retURL=%2F' + theOpp.id + '&oppid=' + theOpp.Oppty_ID_18__c);

This is our new Page Reference for the Lightning.  It is not populating the Quote Name with Opportunity Name, Opportunity, Account Name.
           
PageReference pref = new PageReference('/lightning/o/Quote/new?Name=' +theOpp.Name+'&retURL=%2F'+ '&oppid=' + theOpp.Oppty_ID_18__c);


Any guidance someone could provide me that would be great.
Trouble getting any coverage on my test code to cover anything. 

It is a simple Visualforce page of fields already on the Pagelayout but to make it easier for the users.  
The button is on the Account Record and just pulls up the fields the sales team needs to fill out. 

Here is my Apex:
public with sharing class US_Medical_sales_mandatory {
    
    private ApexPages.StandardController c;

  
     public string getAccountId{get;set;}
       
      public US_Medical_sales_mandatory (ApexPages.StandardController controller)
      {
       
          getAccountid = ApexPages.CurrentPage().getparameters().get('ID');
      }
    

    
 public pagereference US_Medical_Sales_Mandatory()
 {

// you can fetch dummy lookup field value here and process accordingly.
  System.debug('@@@@@@@@@@@'+account.ownerid);
  return null;
 } 
}

Here is my test script:
@isTest
public class US_Medical_sales_mandatory_Test {
  
    Static testMethod void US_Medical_sales_mandatory_Test() {
     
         
        Account a = new Account(
            Name = 'testaccount'           );
        insert a;

      Account newAccount = new Account();
        
     Account acc= [Select ID,Name From Account WHERE Name='testaccount'];
      a.Id=acc.Id;
        a.AERs_in_Dept1__c = 'Manual';
        a.AER_s_in_Dept_2__c = 'Cantel ADV + 2.0';
        a.AER_s_in_Dept_3__c = 'Cantel ADV PT';
         a.AER_s_in_Dept_4__c = 'EVOTECH';
         a.AER_s_in_Dept_5__c = 'Cantel ISA';
         a.AER_s_in_Dept_6__c = 'Cantel ISA';
         a.Average_Numbers_of_Rooms__c = 45;
         a.Brush_Brand__c = 'Pull Thru';
         a.Colon_Volume_Yearly__c = 25;
         a.Department_AER_1__c = 'ENT';
         a.Department_AER_2__c =  'GI';
         a.Department_AER_3__c = 'GI';
         a.Department_AER_4__c = 'GI';
         a.Department_AER_5__c = 'GI';
         a.Department_AER_6__c = 'SPD';
          a.Disposable_Irrigation_Tubing__c =
         a.Disposable_Valves__c = 'Defendo';
         a.EGD_Volume_Yearly__c = 26;
         a.ERCP_Volume_Yearly__c = 26;
         a.EUS_Volume_Yearly__c= 27;
         a.QTY_of_AER_in_Dept_1__c= 78 ;
         a.QTY_of_AER_in_Dept_2__c= 1;
         a.QTY_of_AER_in_Dept_3__c= 1000;
         a.QTY_of_AER_in_Dept_4__c=14;
         a.QTY_of_AER_in_Dept_5__c=8;
 
        
        Test.startTest();
       Update a;
        Test.stopTest();
       
        PageReference ref = Page.US_MEDICAL_SALES_Mandatory;
        test.setCurrentPage(ref); 
            }
}
I have this Test Class code and I am not sure what I am doing wrong to get the 2 errors.

isTest
private class EmailServiceExampleTest
{
    static testMethod void testUnsubscribe() 
    {
       // Create a new email and envelope object.    
       
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
    
       // Create Test record.
       Contact cont = new Contact(firstName='john', lastName='smith', Email='test@test.com', HasOptedOutOfEmail=false);
       insert cont ;
       
       // Test with the subject that matches the unsubscribe statement.
       email.subject = 'Test Contact Email';
       email.plainTextBody = 'Test Contact Email';

       env.fromAddress = 'test@test.com';
       EmailServiceExample obj= new EmailServiceExample();
       obj.handleInboundEmail(email, env );



I am getting these 2 errors:
Line 20 - Invalid Type: EmailServiceExample
Line 21 - Variable does not exist: obj
 
I want the column heading to say "Invoiced" for one group of people and "Actual Sales" for another group of people.  

            
                    <apex:column headerValue="Actual Sales" rendered={!if(!q.IsProcedural__c,true,false)}">
                        <apex:outputText value="{!q.Annual_Actual_Sales__c}" style="width:70px" />
                    </apex:column>

Now this is not rendering anything for anyone.  What am I doing wrong?
**Still Learning**
I am trying to create the Apex Controller that will then be used by the Visualforce page for layouts.  I only want to show the Current Fiscal Period based on Todays date on the Visualforce page.  

Period_FY__c is just a formula field that is a String:  Below is the code for the formula field.
CASE( 
Text(Month(TODAY() )) , 
"1","2", 
"2","3", 
"3","3", 
"4","3", 
"5","4", 
"6","4", 
"7","4", 
"8","1", 
"9","1", 
"10","1", 
"11","2", 
"12","2", 
"" 
)

The code where I am having an error.  If there is a different way this would be written better I am open. (learning)

public with sharing class QuotaRelatedListqtr {

public List <Quota__c> quotas {get;set;}
public List <Business_Plan__c> bp {get;set;}
public List <Period> period {get;set;}
    
Integer FiscalYearStartMonth = 
[select FiscalYearStartMonth from Organization where id=:Userinfo.getOrganizationId()].FiscalYearStartMonth;

String TodaysDate = date.today().format();
     
Public List <Period> Periods = [Select p.Number From Period p 
         Where (p.StartDate <= TODAY AND p.EndDate >= TODAY) and p.type = 'Quarter' Limit 1];


       // Get information about the Quota being worked on
       // Needs to be based on Business Plan per Person 
       // Need to get the correct FY and Correct Quarter based on todays date.    
       // 
public QuotaRelatedListqtr(ApexPages.StandardController controller) {
 quotas = [SELECT Actual_Sales__c, Actual_vs_Quota__c, Annual_Actual_Sales__c, Annual_Quota__c, 
                           Annual_Targeted_New_Business_Sales__c, Business_Plan__c, Fiscal_Period2__c,
                               Quota__c, Sales_Categories__c, Sales_Category_Name__c,  Sales_Needed_to_Hit_Quota__c,Sales_Product_Category__c,
                               Sales_Won__c, Targeted_New_Business__c,Target_vs_Quota__c,Targeted_New_Business_Sales__c
                               FROM Quota__c
                              WHERE Period_FY__c IN :Periods];    
                             
    }
              
}


Here is the Error Message:  Invalid bind expression type of Period for column of type String
I have bolded the line where it is saying the error is.

 
When I have made a field not editable within Visualforce.  I have a process builder that needs to update to update the field.  

When the field is able to be updated then the Process Builder works with no issues.  
I need some help with making this a smaller so it will fit in the formula field.

If(
            Unit_Price_Upside__c = 0, (

TotalPrice/
IF(
     ISPICKVAL(PricebookEntry.Product2.Family,"Service Contracts"),
     Number_of_Years_SC__c,
     IF(
         AND(
                Opportunity.RecordType.DeveloperName="Procedural",
                (PricebookEntry.Product2.Marketing_Division__c="MR" ||
                 PricebookEntry.Product2.Marketing_Division__c="BMG")
                ),
         Value(Text(Opportunity.Number_of_Years__c)),
         1))),
((Quantity *  Unit_Price_Upside__c)/
IF(
     ISPICKVAL(PricebookEntry.Product2.Family,"Service Contracts"),
     Number_of_Years_SC__c,
     IF(
         AND(
                Opportunity.RecordType.DeveloperName="Procedural",
                (PricebookEntry.Product2.Marketing_Division__c="MR" ||
                 PricebookEntry.Product2.Marketing_Division__c="BMG")
                ),
         Value(Text(Opportunity.Number_of_Years__c)),
         1))
         
    
)
)
I have a field on the OpportunityLineItem.To_Business_plan__c that I want when the product is selected it automatically defaults to checked on the Product Selector.  I have highlighted the piece of code not working.  Any help would be much appreciated.  

APEX CLASS:
public with sharing class opportunityProductEntryExtension {


    public Opportunity theOpp {get;set;}
    public Opportunitylineitem opli {get;set;}
    public String searchString {get;set;}
    public List<OpportunityLineItemWrapper> shoppingCart {get;set;}
    public List<PricebookEntry> availableProducts {get;set;}
    public Pricebook2 theBook {get;set;}

    public String toSelect {get; set;}
    public String toUnselect {get; set;}
    public Decimal Total {get;set;}

    public Boolean overLimit {get;set;}
    public Boolean multipleCurrencies {get; set;}

    
    public with sharing class controller {
    public list < opportunitylineitem> objb = [select to_business_plan__c from opportunitylineitem];
    public list <opportunitylineitem> getRecords() {
        if(objb <> null){
            for(opportunitylineitem  opli : objb){
                opli.to_business_plan__c = true;
            }
        }
        return objb;
    }
}

    
 
VisualForce:

                       <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.To_Business_Plan__c.Label}">
                                 <apex:inputCheckbox value="{!s.oli.To_Business_Plan__c}" id="objb"/>
                       </apex:column>

The page renders but the checkbox is not defaulting to checked.

 
I am trying to be a Recall Button on the Quote Page:  I am receiving the error: A problem with the OnClick JavaScript for this button or link was encountered:  Unexpected Identifier.

Apex Class:
global class approvalRecall
{
    webservice static void recallApproval(Id recId)    
    {        
        List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
        req.setAction('Removed');        
        req.setWorkitemId(piwi.get(0).Id);
   
        Approval.process(req,false);
    }
}




{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 


var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 

sforce.apex.execute("approvalRecall","recallApproval",{ID:"{!Quote.Id}"}); 
alert("Approval has been recalled"); 
window.open('/{!Quote.Id}'); 

else 

alert("Recall Cancelled"); 
}{!Quote.Id}
I am getting a couple of errors with the Controller which then gives me an error in Visualforce page.  

I am trying to let the user add multiple rows of information from one screen.  I am trying to allow the user to hit Add in the table so that we can get more information.   I will need another table with the same capability to be able to add another row.  Most of the time we won't need to add a row but I would rather do it right the first time.   I am just learning how to do this so any guidance would be great.



Apex Class
public class MultiAdd
{
    //will hold the Endora records to be saved
    public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();

    //list of the inner class

    public List<innerClass> lstInner

    {   get;set;    }

    //will indicate the row to be deleted

    public String selectedRowIndex
    {get;set;} 
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    //{get;set;}

    ////save the records by adding the elements in the inner class list to lstinner,return to the same page

    public PageReference Save()

    {
        PageReference pr = new PageReference('/apex/MultiAdd');
        for(Integer j = 0;j<lstEndoras.size();j++)
        {
            lstInner.add(lstEndora[j].endora__c);   (error)
        }
        insert lstInner;
        pr.setRedirect(True);
        return pr;

    }

    //add one more row

    public void Add()

    {  

        count = count+1;

        addMore();     

    }

    /*Begin addMore*/

    public void addMore()

    {

        //call to the iner class constructor

        innerClass objInnerClass = new innerClass(count);

        //add the record to the inner class list
        lstInner.add(objInnerClass);   
        system.debug('lstInner---->'+lstInner);           

    }/* end addMore*/

    /* begin delete */

    public void Del()

    {

        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;

    }/*End del*/

    /*Constructor*/

    public MultiAdd(ApexPages.StandardController ctlr)

    {

        lstInner = new List<innerClass>();

        addMore();

        selectedRowIndex = '0';

    }/*End Constructor*/

    /*Endora Class*/

    public class innerClass

    {      

        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */

        public String recCount

        {get;set;}

        public Endora_Information__c endora

        {get;set;}

        /*Inner Class Constructor*/

        public innerClass(Integer intCount)

        {

            recCount = String.valueOf(intCount);       

            /*create a new endora record*/

            endora = new Endora_Information__c();

        }/*End Inner class Constructor*/   

    }
}
    /*End inner Class*/

Error:  Incompatible element type Decimal for collection of MultiAdd.innerClass

Visual Force page  (everything works that is bolded) 
Error: Line 1 Previous load of class failed: MultiAdd: line 28, column 13: Incompatible element type Decimal for collection of MultiAdd.innerClass


<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
    <apex:relatedList list="Endora_Information__c"/>
    <apex:form >
        <style type="text/css">
    .pbTitle {
        white-space: nowrap
             }
        </style>
        <apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
            How many total procedure rooms? &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
            
            <b>PROCEDURE ROOM/QTY</b><p/>
            ENDORA kiosks #45040-73  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
            Workflow Software only (customer provides hardware) #ENDO-777 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
         </apex:pageBlock>
        
         <apex:pageBlock title="Travel Carts">
            How many travel carts will track endoscopes? &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
            <b>TRAVEL CARTS/QTY</b><p/>
            ENDORA kiosks #45040-73  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
            Workflow Software only (customer provides hardware) #ENDO-777 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
         </apex:pageBlock>
        
        
        <apex:pageBlock title="Kiosk Mounts">
            Kiosk mount total by type for procedure rooms:? &nbsp;&nbsp; <p/>
            <b>KIOSK MOUNTS/QTY</b><p/>
            Flush Wall Mount #72233-847  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
            Flush Tilt Wall Mount #72233-849 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
            Arm Wall Mount #72233-848  &nbsp;&nbsp; 
            <apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
            Floor Stand #72233-850 &nbsp;&nbsp;
            <apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
         </apex:pageBlock>

        
        
        
        <apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
        <apex:commandbutton value="Save" action="{!Save}"/>
       

        
        apex:pageblock id="pb1">
        
     
        <apex:repeat value="{!lstInner}" var="e1" id="therepeat">
                <apex:panelGrid columns="5">
                <apex:panelGrid headerClass="Endora">
                    <apex:facet name="header">Del</apex:facet>
                    <apex:commandButton value="X" action="{!Del}" rerender="pb1">
                        <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
                    </apex:commandButton>
                </apex:panelGrid>
                <apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
                    <apex:facet name="header">Department</apex:facet>
                    <apex:inputfield value="{!e1.acct.ShippingCountry}"/>
                </apex:panelGrid>
                    
                <apex:panelGrid >
                    <apex:facet name="header">Floor/Room#</apex:facet>
                    <apex:inputfield value="{!e1.acct.Active__c}"/>
                </apex:panelGrid>
                 
                <apex:panelGrid >
                 <apex:facet name="header">Kiosk Quantity</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
                    
                <apex:panelGrid >
                 <apex:facet name="header">Mount Type</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
                <apex:panelGrid >
                 <apex:facet name="header">Kiosk Quantity</apex:facet>
                    <apex:inputfield value="{!e1.acct.Name}"/>
                </apex:panelGrid>
                    
            </apex:panelgrid>
        </apex:repeat>
       
      </apex:form> 
</apex:page>

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.