+ Start a Discussion
AshishGargAshishGarg 

How to retrieve values from another object in readonly form based on selected fields values

Hi,

 

I have created one custom object and in that object's page layout i need to create a lookup field i.e. for another standard object. On the custom object's page layout i have four another fields ( from the standard object) in read only form. And all these four fields value will get populated based on the lookup field's selected value.

 

I hope i am able to make you understand my issue.

 

Please help me as i am a fresher and new to this technology. I am desperate to learn this and somehow i come to know that i may get solution over here. Thanks

Best Answer chosen by Admin (Salesforce Developers) 
SurekaSureka

Hi,

 

You do not need any code for this.

 

1. Create a lookup feild in the custom object.

 

2. Now create the other 4 feilds as formula feild . for eg. if  one of the other formula feild is "X", then this formula feild will have this value - Account__r.Site - In this example, my lookup feild is to the Account object, and I am retrieving "Site" of the corresponding account.

 

Thanks

 

All Answers

MandyKoolMandyKool

Hi,

 

In order to do this, you will need to write the trigger on "Custom Object" for update or insert.

 

So when the user will select the lookup field this trigger will be fired.

The trigger will pull the corresponding values from your standard object and will set them on the Custom Objects fields.

 

Hope, this will help you!!!

 

If you have any further queries let me know.

 

Thanks,

Mandar.

 

 

 

AshishGargAshishGarg

Hello Sir,

 

can you please give me a sample code for writing such kind of trigger.

SurekaSureka

Hi,

 

Below is my understanding: You have a custom object with 5 feilds - One lookup and 4 other feilds. This lookup feild is to a standard object. Based on the value in the lookup, you need the other 4 feilds to be populated.

 

You can acheive this with the help of formula feild. Create the lookup feild first, and then create the other 4 formula feilds(You will be able to select the corresponding object in the formula feild).

 

Let me know if that helps.

 

Thanks

AshishGargAshishGarg

Hi,

 

thanks for this,

 

can you please provide me a sample code for this.

SurekaSureka

Hi,

 

You do not need any code for this.

 

1. Create a lookup feild in the custom object.

 

2. Now create the other 4 feilds as formula feild . for eg. if  one of the other formula feild is "X", then this formula feild will have this value - Account__r.Site - In this example, my lookup feild is to the Account object, and I am retrieving "Site" of the corresponding account.

 

Thanks

 

This was selected as the best answer
AshishGargAshishGarg

Thanks

 

please provide me a sample formula for this... it would be a greate help

 

 

AshishGargAshishGarg

Thanks it works..:robotwink: