+ Start a Discussion
salesforce@14salesforce@14 

How to get the value from one field in parent object and populate in child object when i click new button in child object.

Hi,
can someone help me to how to figure out the apex class and vf page.

Thanks.
fundooMentalfundooMental
Have you created a button on the record detail page or your query is about a completely separate VF page where you have created a button?
salesforce@14salesforce@14
Not created any button if i click on statndard New Button it redirect to that page where the child object fields displayed.
Ganesh BabuGanesh Babu
Hi Sushma,

There will be a relationship field between parent and child object. you will get parent record id from that field. Using parent id, you can query parent record details. Store the entire record information on an obj variable.

In VF page, create a text field and place the variable in value attribute.


Eg: <apex:inputText value="{!Account.Phone}" id="theTextInput"/>

Thanks,
Ganesh Babu.
fundooMentalfundooMental

For the above requirement you don't need to write any VF or Apex at all. Just create a formula field of type Text on child and the value of this formula field will be the value of the Picklist field in the parent. You click on new button and create the new child record and this field will automatically show the value of the parent picklist value.

Let us know if it doesn't solve your requirement and why

fundooMentalfundooMental
Issue solved? Please care to reply and mark best answer
salesforce@14salesforce@14

Hi fundooMental,

Thanks for your support. 
 I resolved my issue using Class and Page.

Thanks.
Joseph AlstonJoseph Alston
If I select the default "New" button, I am taken to the page where the krunker (https://krunkerio.io) fields for the child item are displayed, even though no such button has been created.