• rivereridanus
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
I am trying to build a single visualforce page which lets you enter an opportunity and oppty line items on a single page. I have a controller extension which manages some of the key pieces. However when I attempt to view the visualforce page I get this message: 

Unable to Access Page
The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 


The button that is calling the page is: 
/apex/Donation_Entry_Form?retURL=%2Fapex%2FDonation_Home2%3Fsave_new%3D1%26sfdc.override%3D1&RecordType=012i0000000Hrcv&ent=Opportunity

My initial thought was that I was missing some URL parameters, but I included all the ones I thought I needed in the button URL and the same issue occurs with that link as when attempting to render the page with no URL parameters at all. I'm not sure in what direction to go next. Can anyone help?  

Thank you!

Here is the visualforce page itself:
<apex:page standardController="Opportunity" extensions="Donation_Entry_Controller" showHeader="true">
<apex:form >
    <apex:pageBlock>
          <apex:pageBlockSection title="Donation Information" columns="2">
              
              <apex:inputField value="{!oppty.Account.Id}" required="true" label="Donor Name:"/>
              <apex:inputField value="{!oppty.CloseDate}" required="true" label="Date of Donation:"/>
              <apex:inputField value="{!oppty.Description}" required="true" label="Description or Details:"/>
              <apex:inputField value="{!oppty.Donation_Designation__c}" label="Primary Designation: "/>
          </apex:pageBlockSection>
           
         <apex:pageBlockSection title="What Is Being Donated?" columns="1" collapsible="true">
         <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
             <apex:column headerValue="Line" rendered="false">
                <apex:outputText value="{!wrapper.ident}" rendered="false"/>
             </apex:column>
             <apex:column headerValue="Item" style="width:175px" >
                <apex:inputField value="{!wrapper.oli.Product2}"/>
             </apex:column>
             <apex:column headerValue="Quantity" style="width:100px" >
                <apex:inputField value="{!wrapper.oli.Quantity}" style="width:100px" />
             </apex:column>
             <apex:column headerValue="Override Price" style="width:100px" >
                <apex:inputField value="{!wrapper.oli.UnitPrice}"/>
             </apex:column>
             <apex:column headerValue="Default Price" style="width:200px" >
                <apex:outputField value="{!wrapper.oli.ListPrice}" style="width:200px" />
             </apex:column>
             <apex:column headerValue="Description" style="width:100px" >
                <apex:inputField value="{!wrapper.oli.Description}" style="width:100px" />
             </apex:column>
         </apex:pageBlockTable>
      
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/> 
      </apex:commandButton>
      
   </apex:pageBlockSection>   
    
   
      <apex:commandButton value="Submit" action="{!save}"/>
    </div>

</apex:pageblock>
</apex:form>
</apex:page>
... and this is the controller extension:
 
public class Donation_Entry_Controller 
{
    public List<OLIWrapper> wrappers {get; set;} 
    public Opportunity oppty {get; set;}
    public static Integer toDelIdent {get; set;}
    public static Integer addCount {get; set;}
    private Integer nextIdent=0;
  
    public Donation_Entry_Controller(ApexPages.StandardController controller)
    {
       oppty = (Opportunity)controller.getRecord();       
       // oppty = new Opportunity();

       wrappers=new List<OLIWrapper>();
       for (Integer idx=0; idx<5; idx++)
       {
          wrappers.add(new OLIWrapper(nextIdent++));
       }
    }
  
    public void delWrapper()
    {
       Integer toDelPos=-1;
       for (Integer idx=0; idx<wrappers.size(); idx++)
       {
          if (wrappers[idx].ident==toDelIdent)
          {
              toDelPos=idx;
          }
       }
   
       if (-1!=toDelPos)
       {
           wrappers.remove(toDelPos);
       }
    }
  
    public void addRows()
    {
        for (Integer idx=0; idx<addCount; idx++)
        {
            wrappers.add(new OLIWrapper(nextIdent++));
        } 
    }
  
    public PageReference save()
    {
        if(oppty!=null)
        {
            oppty.Probability = 100;
            oppty.StageName = '01Ji0000001jfyG'; //Stage = 'Closed'
            oppty.Name = 'General Donation';
            oppty.RecordType.Id = '012i0000000Hrcv'; //Donation Received
            oppty.PriceBook2.Id = '01si0000000HGwf';
            
            insert oppty; 
              //  Account acct = new Account();
        }
        else
        {
            //not relevant code
        }
        
        List<OpportunityLineItem> olis = new List<OpportunityLineItem>();
        for (OLIWrapper wrap : wrappers)
        {
            if(wrap.oli.Name != null)
            {
                wrap.oli.ServiceDate = System.now().Date();
                wrap.oli.OpportunityId = oppty.Id;
                
                olis.add(wrap.oli);
            }
        }
        
        insert olis;
        
        return new PageReference('/apex/Lead_Registration_Complete');

    }
    
    public class OLIWrapper
    {
        public OpportunityLineItem oli {get; set;}
        public Integer ident {get; private set;}
   
        public OLIWrapper(Integer inIdent)
        {
        ident=inIdent;
        oli = new OpportunityLineItem();
        }
    }
}


 

Hi everyone,  I have a VF report that I have made the pulls together a single conceptual record based on information in mutiple different SObjects. I wrote this controller class to feed the report, and it works and does exactly what I need. However, report takes between 20 to 30 seconds to run because the query is seriously not optimized (written that way to avoid hitting governor limits)- sometimes we even get timeout errors and have to wait until another time to run the report.

What I'm trying to do is come up with a way to recode this so that it is more efficient and we don't timeout without hitting governor limits.  I'm not looking for someone to recode it for me, but if anyone has any thoughts on how to do this, I'd really appreciate hearing it!

Thanks in advance!

public class DiaperReportController 
{ 
   public List<DiaperReportDummy> results {get;set;}

   public DiaperReportController()
   {
       results = getResults();
   }

   public DiaperReportDummy[] getResults() 
   { 
      results = new List<DiaperReportDummy>();
      
      //query for all the data 
      Date d = System.today() - 59; //will get all ongoing diaper people who havent gotten a donation in 60 days
      Contact[] allContacts = [select Name, Phone, OtherPhone, Contact_Info_Notes__c, Description, Diapers_Needed__C, Diaper_Size__c, Diaper_Size_Date__c, AccountId, Id, npe01__Primary_Address_Type__c, MailingStreet, MailingCity, MailingState, MailingPostalCode, npe01__Secondary_Address_Type__c, OtherStreet, OtherCity, OtherState, OtherPostalCode from Contact where (npo02__LastCloseDate__c < :d or npo02__LastCloseDate__c = null) and (Diapers_Needed__c = True or Num_Diapers_Dependents__c > 0) order by MailingPostalCode];
      Dependent__c[] allDependents =  [select Contact__c, Name, Diapers__c, Diaper_Size__c, Diaper_Size_Date__c, Gender__c, Age__c from Dependent__c where (Contact__r.Diapers_Needed__c = True or Contact__r.Num_Diapers_Dependents__c > 0)]; 
      Opportunity[] allOpptys = [select Account.Id, CloseDate, Amount, Description, Name, RecordTypeId, Campaign.Id from Opportunity where Is_Last_Donation__c = True and Contact_Is_Ongoing_Diapers__c = True and RecordTypeId = '012i0000000RGFh'];
      OpportunityLineItem[] allOLIs = [select Opportunity.Id, Description, Product2.Name, Quantity, TotalPrice from OpportunityLineItem where Opportunity.Is_Last_Donation__c = True and Opportunity.Contact_Is_Ongoing_Diapers__c = True and Opportunity.RecordTypeId = '012i0000000RGFh'];
      
      //find all the related data and put into dummy class 
      for(Contact c: allContacts) 
      {
      Dependent__c[] lstDeps = new List<Dependent__c>();
      OpportunityLineItem[] lstOLIs = new List<OpportunityLineItem>();
      Opportunity lastopty;
      
         //get the related Dependents 
         for(Dependent__c dep: allDependents) 
         { 
           if(dep.Contact__c == c.id) 
            { 
               
               lstDeps.add(dep);    
            } 
         }
         //get the most recent sent donation
         for(Opportunity opp: allOpptys)
         {
             if (opp.AccountId == c.AccountId)
             {
                 lastopty = opp;
                 break;
             }
             else
             {
                 lastopty = null;
             }
         }
         //get the products of the most recent sent donation- if there is one
         if (!(lastopty == null))
         {
             for(OpportunityLineItem oli: allOLIs)
             {
                 if (oli.OpportunityId == lastopty.Id)
                 {
                     lstOLIs.add(oli);
                 }
             }
         }
         
         //create the Dummy class and add to the result list 
         results.add(new DiaperReportDummy(c, lstDeps, lastopty, lstOLIs)); 
         
      } 
      return results; 
   }
   
   //Inner class to hold relevant details for each Contact
   class DiaperReportDummy 
   { 
       public Contact contact { get; set; }  
       public Dependent__c[] dependents { get; set;} 
       public Opportunity opportunity {get;set;}
       public OpportunityLineItem[] opptylineitems {get;set;}
       
       public DiaperReportDummy(Contact con1, Dependent__c[] dep1, Opportunity opp1, OpportunityLineItem[] oli1) 
       { 
          this.contact = con1; 
          this.dependents = dep1;
          this.opportunity = opp1; 
          this.opptylineitems = oli1;
       } 
   }

}

 
I am trying to figure out how to create a link or button on the custom visualforce pages that override the SF default home pages for Contacts, Accounts, and Leads. The visualforce home pages are just an extended list of all records in that object since my users were getting confused by the original default home page.  

We just got XMM (Extended Mail Merge) enabled in our org, and the only way to get to it seems to be via the default home page- but we don't use those.  I'd like to find a way to put a button or link on the visualforce home page- or at least provide some way for my users to be able to get to it. Anyone have any thoughts or know anything about this?  Any comments are appreciated! 
Hello!

I have a custom controller that I got online and customized for my own environment and use. I have tested it personally and I think it's ready for prod. But I don't know how to write a test case for this type of controller!  I've looked at lots of documentation, but can't seem to find what I"m looking for.

Basically what this controller does is supports the VF page below which dynamically adds or deletes rows in order to add multiple opportunities at a time.

I know how to write a test case for something like the save method, but I need help when it comes to page references and other methods like addrows or deleterows.  

Thank you so much for any help!!

User-added image

public class ManageListController
{
public List<OpportunityWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
 
public ManageListController()
{
  wrappers=new List<OpportunityWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
 
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public PageReference save()
{
  List<Opportunity> opps=new List<Opportunity>();
  for (OpportunityWrapper wrap : wrappers)
  {
   opps.add(wrap.opp);
  }
  
  insert opps;
  
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
}
 
public class OpportunityWrapper
{
  public Opportunity opp {get; private set;}
  public Integer ident {get; private set;}
  
  public OpportunityWrapper(Integer inIdent)
  {
   ident=inIdent;
   opp=new Opportunity(Name='Cash Donation',RecordTypeId='012i0000000Hrcv',StageName='Posted',Probability=100);
  }
}
}
Does anyone know of a way to display a Child's related list at the Parent record level?  I have a custom object with a Master-Detail relationship to the Opportunity object.  We utilize DocuSign and have created the DocuSign envelop button on the child object.  As a result, the Docusign status related list is not available at the Opportunity level.  Is there any way of getting it there?  Thanks

Hi everyone,  I have a VF report that I have made the pulls together a single conceptual record based on information in mutiple different SObjects. I wrote this controller class to feed the report, and it works and does exactly what I need. However, report takes between 20 to 30 seconds to run because the query is seriously not optimized (written that way to avoid hitting governor limits)- sometimes we even get timeout errors and have to wait until another time to run the report.

What I'm trying to do is come up with a way to recode this so that it is more efficient and we don't timeout without hitting governor limits.  I'm not looking for someone to recode it for me, but if anyone has any thoughts on how to do this, I'd really appreciate hearing it!

Thanks in advance!

public class DiaperReportController 
{ 
   public List<DiaperReportDummy> results {get;set;}

   public DiaperReportController()
   {
       results = getResults();
   }

   public DiaperReportDummy[] getResults() 
   { 
      results = new List<DiaperReportDummy>();
      
      //query for all the data 
      Date d = System.today() - 59; //will get all ongoing diaper people who havent gotten a donation in 60 days
      Contact[] allContacts = [select Name, Phone, OtherPhone, Contact_Info_Notes__c, Description, Diapers_Needed__C, Diaper_Size__c, Diaper_Size_Date__c, AccountId, Id, npe01__Primary_Address_Type__c, MailingStreet, MailingCity, MailingState, MailingPostalCode, npe01__Secondary_Address_Type__c, OtherStreet, OtherCity, OtherState, OtherPostalCode from Contact where (npo02__LastCloseDate__c < :d or npo02__LastCloseDate__c = null) and (Diapers_Needed__c = True or Num_Diapers_Dependents__c > 0) order by MailingPostalCode];
      Dependent__c[] allDependents =  [select Contact__c, Name, Diapers__c, Diaper_Size__c, Diaper_Size_Date__c, Gender__c, Age__c from Dependent__c where (Contact__r.Diapers_Needed__c = True or Contact__r.Num_Diapers_Dependents__c > 0)]; 
      Opportunity[] allOpptys = [select Account.Id, CloseDate, Amount, Description, Name, RecordTypeId, Campaign.Id from Opportunity where Is_Last_Donation__c = True and Contact_Is_Ongoing_Diapers__c = True and RecordTypeId = '012i0000000RGFh'];
      OpportunityLineItem[] allOLIs = [select Opportunity.Id, Description, Product2.Name, Quantity, TotalPrice from OpportunityLineItem where Opportunity.Is_Last_Donation__c = True and Opportunity.Contact_Is_Ongoing_Diapers__c = True and Opportunity.RecordTypeId = '012i0000000RGFh'];
      
      //find all the related data and put into dummy class 
      for(Contact c: allContacts) 
      {
      Dependent__c[] lstDeps = new List<Dependent__c>();
      OpportunityLineItem[] lstOLIs = new List<OpportunityLineItem>();
      Opportunity lastopty;
      
         //get the related Dependents 
         for(Dependent__c dep: allDependents) 
         { 
           if(dep.Contact__c == c.id) 
            { 
               
               lstDeps.add(dep);    
            } 
         }
         //get the most recent sent donation
         for(Opportunity opp: allOpptys)
         {
             if (opp.AccountId == c.AccountId)
             {
                 lastopty = opp;
                 break;
             }
             else
             {
                 lastopty = null;
             }
         }
         //get the products of the most recent sent donation- if there is one
         if (!(lastopty == null))
         {
             for(OpportunityLineItem oli: allOLIs)
             {
                 if (oli.OpportunityId == lastopty.Id)
                 {
                     lstOLIs.add(oli);
                 }
             }
         }
         
         //create the Dummy class and add to the result list 
         results.add(new DiaperReportDummy(c, lstDeps, lastopty, lstOLIs)); 
         
      } 
      return results; 
   }
   
   //Inner class to hold relevant details for each Contact
   class DiaperReportDummy 
   { 
       public Contact contact { get; set; }  
       public Dependent__c[] dependents { get; set;} 
       public Opportunity opportunity {get;set;}
       public OpportunityLineItem[] opptylineitems {get;set;}
       
       public DiaperReportDummy(Contact con1, Dependent__c[] dep1, Opportunity opp1, OpportunityLineItem[] oli1) 
       { 
          this.contact = con1; 
          this.dependents = dep1;
          this.opportunity = opp1; 
          this.opptylineitems = oli1;
       } 
   }

}

 
I have a case trigger to count the number of related solutions but, I am receiving a SOQL number of quiries error on an import via data loader.  Therefore, I appear to have an issue with bulkifiying this trigger;

Here is my Trigger;

trigger NumberOfSolutions on case(before update) {
if(Trigger.isUpdate)
{
List<Case> objCase= new List<Case>();
for(Case c:Trigger.New)
{
Integer intNum = 0;
intNum =[select Count() from casesolution where caseID =:c.id];
c.Number_of_Solutions__c =intNum;
objCase.add(c);
}
}
}


Any help would be greatly appreciated.

Joseph
Hello All,
I have two unrelated objects, Enrollment History and Test that are connected to Contact.  However when creating a custom report,
I can choose either contact and EH or Test but not both, trying to use either of these with contact and use a third object only leads me to the Activities object which is a dead end.  I have tried using the Applications object as the main object, and again I can have EH or TESTS but these again lead to the Activities object dead end.

If I start with EH or TEST, my only choice after this is Activities, which is a dead end.

I have tried a junction box between these two objects but to no avail.  Or, I'm creating the box incorrectly.    Can I use a SOQL formula to bring the information I need over into the report.  Or if anyone could shed light on creating a junction box for this dilemma, I would appreciate it.

Thank you.

 
Hello!

I have a custom controller that I got online and customized for my own environment and use. I have tested it personally and I think it's ready for prod. But I don't know how to write a test case for this type of controller!  I've looked at lots of documentation, but can't seem to find what I"m looking for.

Basically what this controller does is supports the VF page below which dynamically adds or deletes rows in order to add multiple opportunities at a time.

I know how to write a test case for something like the save method, but I need help when it comes to page references and other methods like addrows or deleterows.  

Thank you so much for any help!!

User-added image

public class ManageListController
{
public List<OpportunityWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
 
public ManageListController()
{
  wrappers=new List<OpportunityWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
 
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new OpportunityWrapper(nextIdent++));
  }
}
 
public PageReference save()
{
  List<Opportunity> opps=new List<Opportunity>();
  for (OpportunityWrapper wrap : wrappers)
  {
   opps.add(wrap.opp);
  }
  
  insert opps;
  
  return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');
}
 
public class OpportunityWrapper
{
  public Opportunity opp {get; private set;}
  public Integer ident {get; private set;}
  
  public OpportunityWrapper(Integer inIdent)
  {
   ident=inIdent;
   opp=new Opportunity(Name='Cash Donation',RecordTypeId='012i0000000Hrcv',StageName='Posted',Probability=100);
  }
}
}