+ Start a Discussion
Luik LaraLuik Lara 

Visualforce Button directing to wrong page


I have been trying to solve this for ages and can not figure it out (I am not a developer). 
User-added image
I modified someone else's code to build a visualforce page to show product revenue schedules (above). Instead of the 'Edit Schedule' button, I am trying to show that smaller down carrot icon that reps can select to then click 'edit'. In addition, the current button shows the edit product page instead of the edit revenue schedule page. Can someone please advise? 

Here is the code:
<apex:page standardController="Opportunity" action="{!getOLIS}" tabStyle="Opportunity" extensions="OpportunityScheduleExtension" lightningStylesheets="true">
 <apex:form >
     <apex:pageBlock >
     <apex:pageBlockTable value="{!lstOLIS}" var="lst" >
          <apex:column headerValue="Product" value="{!lst.Product_Name2__c}"/>
          <apex:column headerValue="Date" value="{!lst.ScheduleDate}"/>
          <apex:column headerValue="Revenue" value="{!lst.Revenue}"/>
          <apex:column ><apex:commandButton action="{!edit}" value="Edit Schedule" id="OpportunityLineItemScheduleMultiEdit"/></apex:column>

public with sharing class OpportunityScheduleExtension {
    Opportunity objOpp;
    public list<OpportunityLineItemSchedule> lstOLIS {get;set;}
    public OpportunityScheduleExtension(ApexPages.StandardController controller) {
        this.objOpp= (Opportunity)controller.getRecord();
    public void getOLIS(){
        lstOLIS = new list<OpportunityLineItemSchedule >();
        for(OpportunityLineItemSchedule objOLIS:[Select Id, ScheduleDate, Revenue,
                                                 from OpportunityLineItemSchedule 
                                                 where OpportunityLineItem.OpportunityId =:objOpp.Id] ){
ANUTEJANUTEJ (Salesforce Developers) 
Hi Luik,
According to my understanding you would like to have an icon on the button instead of the edit schedule can you try changing the below code from :
<apex:column ><apex:commandButton action="{!edit}" value="Edit Schedule" id="OpportunityLineItemScheduleMultiEdit"/></apex:column>


<apex:column ><apex:commandButton action="{!edit}" iconName="edit" id="OpportunityLineItemScheduleMultiEdit"/></apex:column>

Can you please check this once. In case if this helped can you please choose this as the best answer so that it can be used by others in the future.

Luik LaraLuik Lara
Hello Anutej --

Thanks so much for your help! The button worked however, it is still taking me to the wrong page. It is meant to take me to the Line Item Schedule Edit area but it is taking me to the product editing area. Any ideas?

ANUTEJANUTEJ (Salesforce Developers) 
Luik, can you try disabling the "product editing area" and then check if the issue still persists there could be an error with the page reference or the redirection link that you are using in the code.

Also can you try if giving the "product editing area" in the code does the button redirect to "Schedule Edit area"