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
Guru Vemuru 1Guru Vemuru 1 

How fetch data from other object through looUp?


Hi everyone,
I have two objects (Travel Request and Expense) and there is lookup relation between them. Lookup field in Expense will select the record from Travel. When i select Lookup field some fields in Expense map the data from travel.



When i select Lookup Field Travel Request then Fields like Period From,Period To,Brach,Department fetch data automatically from Tavel Request.
Please tell me how can i do it

 .User-added image
Sandeep WaliaSandeep Walia
Hi Guru,

I am guessing that you are using a custom visualforce page. If that is the case you would have to query the data from Travel Request. Once that data is fetched you can easily map the data on the child object and rerender VF page.
You can share your controller code in case you require further help.

Hope this helps, 
Sandeep
GulshanRajGulshanRaj
Hi Guru,

If Period From,Period To,Brach,Department are read-only fields, then I would suggest to use formula field instead of input field. So, idea is 
In Expense object create follwing formula fields:
1) Travel_request__r.Period_From__c
2) Travel_request__r.Period_To__c
3) Travel_request__r.Branch__c
4) Travel_request__r.Department__c

Please let me know if you have any question.

Thanks
Gulshan Raj