Skip to main content
Shravya Rama が「#Apex」で質問
I am making the current user's username and phone number as the default values for the lookup field Fahrer and text field Contact number through constructor. But when I change the lookup field to any other value, I want my contact number to also get updated. But my method is not getting called from the Fahrer look up field. Can anybody suggest a work around.

VF PAGE

<apex:inputField label="Fahrer" value="{!res.Fahrer__c}" >

<apex:actionSupport action="{!LoadingUserDetails}" rerender="out" />

</apex:inputField>

<apex:inputField label="Contact Nummer" value="{!currentuser.phone}" rendered="true" id="out" />

Class

 

public class CarSharingClass {

public string UserName = UserInfo.getUserId() ;

public Reservation__c res{get; set;}

public user currentuser{get;set;}

public CarSharingClass (ApexPages.StandardController stdController) {

res.Fahrer__c = UserName;

currentuser=[Select Id,phone from User where Id=:res.Fahrer__c limit 1];

system.debug('currentuser:'+currentuser);

res.Contact_Number__c = currentuser.phone ;

}

public void LoadingUserDetails(){

currentuser=[Select Id,phone from User where Id=:res.Fahrer__c limit 1];

system.debug('changeduser:'+currentuser);

res.Contact_Number__c = currentuser.phone ;

}

}

 
3 件の回答
  1. 2017年1月4日 11:28
    I got to know that action support doesnt work well with look up fields. I found a work around which involves to create a button and call the same method to retrieve values.
0/9000