0

I have a custom made action in the standard contact page(call it "myaction") and to that action i have given a another URL say "/apex/mypage" . So when you click on the action "myaction" it redirects you to the page "mypage".

I am doing this using page reference, the standard way. For clear understanding i have the page below

<-----------------myaction is linked to vf page apex1------------------>

<apex:page controller="mycontroller" action="{!redirect}">
</apex:page>

<-----------------------controller: mycontroller ----------------------->

global class mycontroller{
public Contact contact {get;set;}

 public mycontroller(){
  Id id = ApexPages.currentPage().getParameters().get('id');
  contact= (id == null) ? new Contact() :[SELECT AccountId, Phone FROM     Contact WHERE Id = :id];

 public Pagereference redirect(){
        PageReference redirect = new PageReference('/apex/mypage');
        redirect.setRedirect(true); 
        return redirect;
  }
 }
}

<---------------------mypage----------------------->

<apex:page controller="mycontroller">
<apex:inputField id="phoneId" value="{!Contact.phone}"/>
</apex:page>

here I am not able to get the value of contact.phone! it comes in as empty without any value. I am trying to communicate between two windows here maybe the current page does not give it since it is loaded after. I need help. Kindly suggest any other way to obtain my phone number in mypage. NOTE: This is lightning and not classic. Dunno if it makes any difference.

1 Answer 1

0

A small change in controller can make it work

global class mycontroller{
public Contact contact {get;set;}

 public mycontroller(){
  Id id = ApexPages.currentPage().getParameters().get('id');
  contact= (id == null) ? new Contact() :[SELECT AccountId, Phone FROM     Contact WHERE Id = :id];

 public Pagereference redirect(){
        Id recId = ApexPages.currentPage().getParameters().get('id');
        PageReference redirect = new PageReference('/apex/mypage?id='+recId );
        redirect.setRedirect(true); 
        return redirect;
  }
 }
}
0

You must log in to answer this question.

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