Hi I have a parent object detail page opened . I have added a VF component for displaying child object For Ex Approval__c parent object page has a VF component to add comments which is done through diff custom object.

Now I have a add comment button on that component .When I click on that component and try to call my other page which is using standard controller as that object gives this error

Visualforce Error Id value ghcK0000003Xuut is not valid for the Comments__c standard controller

How should I handle this error as the redirection from a parent object page to child object creation through standard controller

Below is the code where i am redirecting from that button

<apex:component controller="CommentsCustomController" allowDML="true" access="global" >
     <apex:pageBlock Title="Comments">   
   <apex:commandButton value="Add Comments" title="Add comments" onclick="window.location='/apex/CommentSectionPage?id={!ApprovalId}&Page={!$CurrentPage.Name}&context=Approval'; return false;" /> 

Now the code of the CommentSectionPage page where I am using standard controller

<apex:page standardController="Comments__c" extensions="CommentsExtensionController">
 <apex:form >
 <apex:pageBlock title="New Comment" mode="Edit" >
   <apex:pageBlockButtons >  
  <apex:commandButton value="Save" action="{!Save}"/>
  <apex:commandButton value="Cancel" action="{!Cancel}"/> 
   <apex:pageBlockSection columns="2" title="Information">
     <apex:outputField value="{!Comments__c.ID}" label="Approval" />
     <apex:inputField value="{!Comments__c.Business_Justification__c}"/>   
     <apex:inputField value="{!Comments__c.Confidential__c}"/>   


Now the extension controller code

public with sharing class CommentsExtensionController{
public Id ApprovalID {
  Public String ApprovalPage;
    Public String context {get;set;}
      public String loggedInUserName{set;get;}
       Public String title {
  private ApexPages.StandardController controller {get; set;}
  public CommentsExtensionController() {
        ApprovalID = ApexPages.CurrentPage().getParameters().get('id');
        ApprovalPage = ApexPages.CurrentPage().getParameters().get('Page');
      context = ApexPages.currentPage().getParameters().get('context');
       // system.debug('PageNAme##' + ApprovalPage);
        if (context == 'Approval' || context == 'Workspace') 
            title = 'Add Comments to Approval';
     public CommentsExtensionController(ApexPages.StandardController controller) {
      this.controller = controller;


1 Answer 1


When you use a standard controller, the id parameter in the URL must belong to the same object.

For example, if you are using the Comments__c standard controller, the id parameter must have a Comments__c record's Id. In your case, you are sending the Approval__c record's Id which is why you are getting an error.

Update your URL to use a different parameter name instead of id.


and in your custom controller you can use

ApprovalID = ApexPages.CurrentPage().getParameters().get('approvalid');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .