+ Start a Discussion
SainSain 

Popup fields not getting populate with values while clicking on formula field on custom detail page

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