function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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

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

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?
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"/>

Ganesh Babu.

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

Issue solved? Please care to reply and mark best answer

Hi fundooMental,

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

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