3

I have a visualforce page that has a list of opportunity products and in this there is a column where you can either create a new related item or lookup an existing item (of a custom object). Looking up an existing item is working fine, but creating a new one and returing to this page is not working for me.

When creating a new item, I have it currently working so that after clicking save on the standard edit page using saveurl, it returns to my visual force page. The next thing I need to happen is that there needs to be an id of the opportunity product passed with the saveurl so that I know which opportunity product to add this item I just created to.

Here is the section of my visualforce page where I create the parameter:

 <apex:column headerValue="">    
            <apex:commandButton action="{!onCreateNew}" value="Create New Item">
             <apex:param value="{!a.Id}" assignTo="{!aID}" name="aID"/>
            </apex:commandButton>              
 </apex:column>

Here is the section of my controller where I create the page reference:

public String aID { get; set;}
public PageReference onCreateNew(){
   return new PageReference('/a0W/e?saveURL=%2Fapex%2FOpptProdEngineeringEdit?id=' +
   ApexPages.currentPage().getParameters().get('Id') + '%26passID%3D' +
   aID +'&cancelURL=%2Fapex%2FOpptProdEngineeringEdit?id=' +
   ApexPages.currentPage().getParameters().get('Id') +
   '&RecordType=012g00000000JWI'); 
}

This section of my controller:

'%26passID%3D' + aID

is where I'm trying to pass the ID of "a" in the saveurl... but no matter what I do it is returning null. Any suggestions?

1
  • Unencoded question mark in the URL for a start... '/a0W/e?saveURL=%2Fapex%2FOpptProdEngineeringEdit?id=' Dec 26, 2013 at 19:50

1 Answer 1

4

Not sure if it is still an issue, but here is a link to a blog post from a few years back claiming that CommandButton doesn't actually invoke the setter.

http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/

He brings up 2 recommendations:

  • use CommandLink and style it to look like a CommandButton
  • rerender a hidden PageBlock section (which apparently invokes the setter)
1
  • 1
    Thank you! This does appear to still be an issue, I just tested it out by switching CommandButton to CommandLink to try it out and it works fine now. I'll give that restyling a try. Thanks again!
    – Katie Swol
    Dec 26, 2013 at 15:38

You must log in to answer this question.

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