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
SainSain 

Id value is not valid for the object__c standard controller

Hi,

Iam trying to get populate field values into popup page while cliking on formula field on custom detail page.  

getting error: Id value is not valid for the Visitor__c standard controller

and also values not populating popup fields.

VF Page:

<apex:page standardController="Visitor__c" sidebar="false" extensions="CustomVisitorDetailExt" >
<script>
 var newWin=null;
 
 function openLookupPopup(mid)
 {
  var url="/apex/PopUpforVisitor?id=" +mid;
  <!--var url="/apex/PopUpforVisitor";-->
  newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
  if (window.focus) 
  {
   newWin.focus();
  }
    
     return false;
    }
       
 function closeLookupPopup()
 {
    if (null!=newWin)
    {
       newWin.close();
    }  
 }
</script>
<apex:form >
<apex:actionFunction name="VisitorAddress" action="{!VisitorAddress}" rerender="accinfo, msgs" >
<apex:param name="recordId" value="" assignTo="{!recordId}"/>
</apex:actionfunction>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection Title="Visitor Details:" collapsible="false" id="accinfo">
<apex:outputField value="{!Visitor__c.name}"/>
<apex:outputField value="{!Visitor__c.Gender__c}"/>
<apex:outputField value="{!Visitor__c.Email__c}"/>
<apex:outputField value="{!Visitor__c.Phone__c}"/>
<apex:outputField value="{!Visitor__c.Patient__c}"/>
<apex:outputField value="{!Visitor__c.Relashionship__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection Title="Address Information:" collapsible="false">

<apex:inputField value="{!Visitor__c.Current_Address__c}" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}');"/>
<!--<apex:inputField value="{!Visitor__c.Current_Address__c}" onclick="openLookupPopup('{!myd}');return false;"/>-->
 
  <!--<apex:outputText value="{!Visitor__c.Current_Address__c}"  />
  <apex:outputlink onclick="window.showModalDialog('\apex\PopUpforVisitor')" target="_blank"  value="/{Visitor__c.id}" > {!Visitor__c.Current_Address__c}
   <apex:actionSupport event="onClick" action="{!VisitorAddress}" reRender="result,mypage" status="status"/>
  </apex:outputlink>-->
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Popup VF Page:

<apex:page standardController="Visitor__c" sidebar="false" showHeader="false" extensions="CustomVisitorDetailExt">
<apex:form >
<apex:pageBlock >

<apex:pageBlockSection Title="Address Information:" collapsible="false" columns="1">
  <!--<apex:repeat value="{!$ObjectType.Visitor__c.fieldsets.Address}" var="fValue">
                 <apex:outputfield value="{!Visitor__c[fValue]}"/>
             </apex:repeat>-->
<apex:inputField value="{!Vist.Address_Line1__c}"/>  
<apex:inputField value="{!vist.Address_Line2__c}"/>  
<apex:inputField value="{!vist.City__c}"/>  
<apex:inputField value="{!vist.State__c}"/>  
<apex:outputField value="{!vist.PinCode__c}"/>  
<apex:inputField value="{!vist.Land_Mark__c }"/>  
 
          
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Class:

public with sharing class CustomVisitorDetailExt {
public visitor__c vist {get;set;}
public id recordId {get;set;}
public id myd {get;set;}

public ApexPages.StandardController standardCon;
    public CustomVisitorDetailExt(ApexPages.StandardController con) {
    standardCon=con;
    vist =new visitor__c();
  myd=apexpages.currentpage().getparameters().get('recordId');
System.debug('>>>>urlid' +myd);
    }
public PageReference VisitorAddress(){
PageReference page=new PageReference('/apex/PopUpforVisitor?id=' +myd);

 //visitor__c vis= (visitor__c) standardCon.getRecord();
    vist= [select Address_Line1__c,Address_Line2__c,City__c,PinCode__c,State__c,Land_Mark__c from visitor__c where id =: myd ];
    //vist.Address_Line1__c=vis.Address_Line1__c;
    //vist.Address_Line2__c=vis.Address_Line2__c;
    //vist.Address_Line1__c=apexpages.currentpage().getparameters().get('vis.Address_Line1__c');
    //vist.Address_Line2__c=apexpages.currentpage().getparameters().get('vis.Address_Line2__c');
return page;
}
}

Please help me to solve this issue.

Regards,
Sain
Best Answer chosen by Sain
Himanshu ParasharHimanshu Parashar
Hi Sain,

You are getting this error because you are using Visitor__c as standard controller but you are not passing Visitor__c record id or passing any different id.

Pass a Visitor__c object record id and this issue will get resolved.


Thanks,
Himanshu

All Answers

Himanshu ParasharHimanshu Parashar
Hi Sain,

You are getting this error because you are using Visitor__c as standard controller but you are not passing Visitor__c record id or passing any different id.

Pass a Visitor__c object record id and this issue will get resolved.


Thanks,
Himanshu
This was selected as the best answer
William TranWilliam Tran
When calling your VF page, what do you pass it?  as a parameter? 

try passing id=yyyyyyyyyyyyyyy

so you can have ...../apex/yourvf?id=yyyyyyyyyyyyyyy
the id is a real id of the VIsitor__c

Thx
SainSain
Thanks for ur support Himanshu and william.