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
Mohit S.Mohit S. 

'New' Command button on VF page not opening new VF page on Case detail page

On the CASE object detail page, I have created a Case Comments VF page (Secure_Message_Comments_VF) as a component on Case object detail page. The 'New' button on this VF page should open the 'Case Comment Edit' page (NewCaseComments_VF) on Case detail page itself, but it is opening the 'Case Comment Edit' page within that component instead. Below is the command button VF code. Please advise.

<apex:page standardController="Case" extensions="CaseCommentRelatedListExt">
<apex:form >
    <apex:pageBlock >
    
    <apex:pageBlockButtons location="top">
           <apex:commandButton value=" New " action="{!"/apex/NewCaseComments_VF"}" />
    </apex:pageBlockButtons>
    
        <apex:pageBlockTable value="{!Case.CaseComments}" var="c">
            <apex:column width="28%" headerValue="Date" value="{!c.createddate} ({!c.CreatedBy.Name})" />
            <apex:column headerValue="Comment" value="{!c.CommentBody}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Do I need to specify parent_id of the case or anything else? Please help with the solution.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help you

<apex:page standardController="Case" extensions="CaseCommentRelatedListExt">
<apex:form >
    <apex:pageBlock >
    
    <apex:pageBlockButtons location="top">
           <apex:commandButton value=" New " action="{!"/apex/NewCaseComments_VF?parent_id={!case.id}"}" />
    </apex:pageBlockButtons>
    
        <apex:pageBlockTable value="{!Case.CaseComments}" var="c">
            <apex:column width="28%" headerValue="Date" value="{!c.createddate} ({!c.CreatedBy.Name})" />
            <apex:column headerValue="Comment" value="{!c.CommentBody}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Please let us know if this will help you