0

I have included a piece of my apex class from a customized product selector. What I am trying to do is to create a custom button on my visualforce page and direct my users to the new quote they want to create from the products they have selected on the opportunity. When Input the code below I get this error:

Unable to Access Page The value of the "oppid" 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.

Is there another way I can get the products they select to save onto the opportunity and create a quote (go to the quote new edit page) all within the same button?

public PageReference onCreateQuote(){

    // If previously selected products are now removed, we need to delete them
    if(forDeletion.size()>0)
        delete(forDeletion);

    // Previously selected products may have new quantities and amounts, and we may have new products listed, so we use upsert here
    try{
        if(shoppingCart.size()>0)
            upsert(shoppingCart);
    }
    catch(Exception e){
        ApexPages.addMessages(e);
        return null;
    }  

    return new Pagereference('/0Q0/e?retURL=%2F{!Opportunity.Id}&oppid={!Opportunity.Id}');
}

1 Answer 1

2

This is where your problem is

return new Pagereference('/0Q0/e?retURL=%2F{!Opportunity.Id}&oppid={!Opportunity.Id}');

You have mixed up visual force and apex. {, ! are all Visualforce specific symbols, if you need to provide the oppty ID and retURL all you do is

//Get the current opportunity ID.

String Opportunity_ID = ApexPages.currentPage().getParameters().get('id')
return new Pagereference('/0Q0/e?retURL=%2F'+Opportunity_ID+'&oppid='+Opportunity_ID);
1
  • Thanks Rao! I found out that this works for me: PageReference pref = new PageReference('/0Q0/e?retURL=%2F' + theOpp.Id + '&oppid=' + theOpp.Id); return pref; Commented Apr 3, 2014 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .