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
MagnetismMagnetism 

Auto populate a field with a field from another object which is ls also a lookup field in another object

I am trying to crate a field on a custom object B and trying to populate that with a custom field value on Account object. that field on Account is a look up on the user object. I am using a trigger to do this, help needed to know how to relate these object records to assign the value to the auto populate field. Also what would be the best type to create this field type to be?
Daniel B ProbertDaniel B Probert
hi is there a relationship between object b and account?

post what code you have so far as well so i can understand when you want object b populated - i.e. when the account is inserted/deleted or when object b is inserted/deleted

thanks
dan
Vinit_KumarVinit_Kumar
So,As far as I can understand you have 3 level of relationship :-

Object B -> Account -> User

If this is correct,you need to query the related field value in SOQL using relationship field  in you Trigger and then you can populate your custom object B record.

Go through the below link to learn about SOQL relationship query :-

http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm

Hope this helps !!