You need to sign in to do that
Don't have an account?
How to redirect from VF page to Add Products and back
I am failing big time. The code below is what I have and it appears to be populating the retURL parameter correctly but this doesn't work at all. If you hit cancel in the add products tool or save it always returns you to the opp, not the visualforce page which is what I want.
Does anyone know of other URL parameters I need to add to make this work? Is it even possible?
Page:
<apex:page controller="addProductsRedirect">
<apex:outputField value="{!opp.Id}"/>-
<apex:outputField value="{!opp.Name}"/>
<apex:form >
<apex:commandLink value="Add Product" action="{!addProduct}">
<apex:param name="addProductsURL" value="{!URLFOR($Action.OpportunityLineItem.AddProduct)}" assignTo="{!addProductsURL}"/>
</apex:commandLink>
</apex:form>
{!URLFOR($Action.OpportunityLineItem.AddProduct)}
</apex:page>
Controller:
public class addProductsRedirect {
Opportunity opp;
public String addProductsURL {get; set;}
public Opportunity getOpp(){
if(opp == null){
opp = [select Id, Name from Opportunity limit 1];
}
return opp;
}
public PageReference addProduct(){
PageReference p = new PageReference(addProductsURL );
p.getParameters().put('addTo',opp.Id);
p.setRedirect(true);
return p;
}
}
Much thanks,
Jason
You might be able to use some sneaky / hacky AJAX on the Opportunity... inline s-control (quick before they go away :smileytongue: ) to check the history to see where the user came from and if they were on your visualforce page then redirect the browser to the desired page.
Not ideal, but the only thing I can think of.
I wish that you could use triggers to send a user to a specific PageReference.
Ya.....I've got one of these hidden redirects already with an inline VF page for something else and I really don't want to add blind actions. Users are easily confused when they start getting sent all over the place automatically.
The user's do access this tool from the opportunity so they would only need to click a button to get back but it is the little things like this that make your app seem like it's not finished.
If there is no way to make this work I'll either leave it as is or build a very lightweight Add Products functionality.
Just create add product functionality, I did the same way :)
Is it possible to have an iframe in a visualforce page that would display the product entry page? It would be tough to get it centered just right so that the header and sidebar are hidden... but that could be pretty cool. The 'wrapper' visualforce page can then poll to see when the products are actually added (since you can't have the frame and the page talk directly) and then redirect or any other action when products are detected.
Kind of wacky, I know... but it might be wacky enough to work :-).
Hey Mr TehNrd
There should be a retURL parameter that will work automatically. The key's case sensitive, so you might also want to try 'retUrl':
You'll also have to urlencode the retURL value.
Wes
Rebuilding something that already exists would be my last option.
This is not a bad idea but there could be a five second delay. It doesn't seem like much but I could see that confusing some users. What I may be able to do is open a popup type window that has the iframe for the add products functionality and then have a close button for this popup. When the close button is clicked I could then query for the new products.
The weird thing about this is that in the iframe, after the products are added, they will see the opportunity detail page, header, and sidebar in the iframe, in the VF page which has its own side bar and header.
Still debating on what to do but leaning towards doing nothing and letting the user get dumped back at the opportunity.
Negatron. For some reason this retURL does not work with the standard Add Products functionality.
"Negatron"..haha...
Yeah, the only time the retURL would get used if if the user hits "Cancel"... saving the products always ignores the retURL.
System.Exception: pricebookentry is not searchable
Got it. Percent symbol, not asterisks.
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=17701&query.id=362605#M17701
weznolte/TehNrd, would either of you mind sharing your code for recreating the Add Products page?
Our organization is frustrated with the inability to customize the Multi-Line Item List page after the Add Products screen (such as the arbitrary fixed-width text fields and inability to apply conditional filters), and from what I've researched, the only way to customize the logic of that page is to recreate the Add Products page before it.
I'm a decent VF coder, but not a virtuoso, so am a little concerned that any replacement I make for it will be far inferior to the 'stock' Add Products screen.
If you wouldn't mind sharing I'm sure others would benefit from your experience in the area, as well :)
[EDIT: Just stumbled on Jeff Douglas' demo for a very similar feature, here: http://blog.jeffdouglas.com/2009/01/13/apex-search-with-checkbox-results/. I'm pretty sure I can leverage this into what I need. It doesn't have all the nice filter options that the default Add Products solution has, but it should work for us in a pinch]
Hi,
Reading the end parts of this thread: if you want to redirect after Save, you can use saveURL , as in
Pierre Eymard
pierre.eymard@saaspoint.com
Saaspoint
London, UK