function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Luik LaraLuik Lara 

CommandLink opening wrong page

Hello everyone!

I am using apex:commandLink for a VF list page but it is opening the wrong edit page. The edit button is currently opening the edit opportunity product details and I need it to open the Product Line Item schedules instead (this page: /related/OpportunityLineItemSchedules/view). I have tried using different actions, a custom URL, and a ton of other options but I can't get anything to work. Does anyone have an answer? 

Thanks! 

VF page with the button: 
User-added image
Current 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.OpportunityLineItem.Product2Id}"/>
          <apex:column headerValue="Date" value="{!lst.ScheduleDate}"/>
          <apex:column headerValue="Revenue" value="{!lst.Revenue}"/>
         <apex:column ><apex:commandLink action="{!edit}" value="Edit" id="EstablishOpportunityLineItemSchedules"/></apex:column>
     </apex:pageBlockTable>
     </apex:pageBlock>
 </apex:form>
</apex:page>
 
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 >();
        system.debug('objOpp---------->'+objOpp);
        for(OpportunityLineItemSchedule objOLIS:[Select Id, ScheduleDate, Revenue,
                                                 OpportunityLineItem.Product2.Name,
                                                 Description,Product_Name2__c, NAME__c
                                                 from OpportunityLineItemSchedule 
                                                 where OpportunityLineItem.OpportunityId =:objOpp.Id] ){
            lstOLIS.add(objOLIS);                                             
        }
    }    
}

 
Best Answer chosen by Luik Lara
Danish HodaDanish Hoda
Sorry for that,please update the code with this:
<apex:column headerValue="Edit"> <apex:outputLink value="/{!lst.id}/e">Edit</apex:outputLink> </apex:column>

All Answers

Danish HodaDanish Hoda
Hi Luik,
Please try this:
<apex:column headerValue="Edit">
 <apex:outputLink value="/{!lst.id}/e"></apex:outputLink>
</apex:column>
Luik LaraLuik Lara
Hi Danish --

Thanks for the response! Unfortunately, now the edit button is gone from the page entirely. 
Danish HodaDanish Hoda
Sorry for that,please update the code with this:
<apex:column headerValue="Edit"> <apex:outputLink value="/{!lst.id}/e">Edit</apex:outputLink> </apex:column>
This was selected as the best answer