You need to sign in to do that
Don't have an account?
Product List Custom Button
I'm trying to create a custom button that can be added to the Product List page that can invoke an external web service to load a few products from the external service into the Salesforce products. I built a custom controller using a StandardSetController as shown below:
public class PM3ProductListController {
private ApexPages.StandardSetController theSetController;
private String theId;
public PM3ProductListController (ApexPages.StandardSetController controller) {
this.theSetController = controller;
this.theId = ApexPages.currentPage().getParameters().get('id');
}
// Code we will invoke on page load.
public PageReference testSend () {
if (this.theId == null) {
// Display the Visualforce page's content if no Id is passed over
return null;
}
// LOAD PRODUCTS
PageReference pageRef = new PageReference('/' + this.theId);
pageRef.setRedirect(true);
return pageRef;
}
}
I then created a VF page:
<apex:page standardController="Product2"
recordSetVar="products"
extensions="PM3ProductListController"
action="{!testSend}"
>
<apex:sectionHeader title="Loading Products..."/>
<apex:outputPanel >
If you're seeing this, an error occurred.
</apex:outputPanel>
</apex:page>
I then added a custom button to the Product List page to load that page. For some reason, it never redirects and just lands on the VF page above.
Does anyone see any obvious errors in my code and/or is there a better way to accomplish what I'm trying to do?
Thanks in advance.