You need to sign in to do that
Don't have an account?
AMAN SINGH 24
hello all, I am using action support to fill the phone number from account but it is not working
<apex:page standardController="Contact" extensions="V_sg1" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!Contact.Lastname}" />
<apex:inputField value="{!Contact.AccountID}" >
<apex:actionSupport event="OnChange" action="{!phone}" />
</apex:inputField>
<apex:inputField value="{!Contact.phone}" />
<apex:inputField value="{!Contact.Fax}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class V_sg1 {
public contact con;
public V_sg1(ApexPages.StandardController controller) {
con=(contact)controller.getRecord();
}
public PageReference phone() {
Account acc=[select id,phone from Account where id=:con.AccountID];
con.phone=acc.phone;
return null;
}
}
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!Contact.Lastname}" />
<apex:inputField value="{!Contact.AccountID}" >
<apex:actionSupport event="OnChange" action="{!phone}" />
</apex:inputField>
<apex:inputField value="{!Contact.phone}" />
<apex:inputField value="{!Contact.Fax}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class V_sg1 {
public contact con;
public V_sg1(ApexPages.StandardController controller) {
con=(contact)controller.getRecord();
}
public PageReference phone() {
Account acc=[select id,phone from Account where id=:con.AccountID];
con.phone=acc.phone;
return null;
}
}
Controller class is same and dont forget to pass the id of the contact in the url like '?id=contactid'.
thanks in advance
I think you donot want to pass the id from url, if that the case you can refer the below code for your requirement. The page has been created like that it will give the user the chance to create a new contact .The user can choose the account he wants to add and phone no field will automatically update with the choosen account's phone no.The fax field I have left for user choice.