function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rivereridanusrivereridanus 

"Unable to access page" due to invalid id parameter (in URL perhaps?). Need help to fix

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();
        }
    }
}