+ Start a Discussion
sandra_AB34sandra_AB34 

Get details from lookup record

Hi,
 
I've looked through communities and I think this is maybe a feature which is being developed for the next release, but wondered if anyone knows of a way to do this in the mean time.
 
I have created an s-control to create a custom object, prepopluating it with certain fields from both the contacts and accounts objects.  This is working great.  However, I have now added a custom lookup field to the contacts object.  I want to get details from this lookup object but I can't seem to reference it in any way apart from the name or id.
 
Is this currently possible?  Is there a way to reference the fields of a lookup object?
 
Thanks
 
Sandra
KringoKringo
I am trying to do something similar and would love a nudge in the right direction. I have a custom object that has a master detail look-up to Account. I have created a field called "Account Site" on the custom object and would like to be able to fill this with the site information from the related Account record

Ideally I would like to have an scontrol update this field upon record save but any solution would be welcome.

sorry if this detracts from the original post but I thought it was similar enough to forgo starting a new thread.
sean33043sean33043
Sounds like you want to read fields on another object and you have the id for that object. You can use the sforce.connection.retrieve().
Code:
<!-- these are needed -->
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/10.0/connection.js"></script>
<!-- -->

// get the Id of the foreign object from current object
parent_id = "{!example__c.parentid__c}";

// query the foriegn object with the given Id and source object
var getSomeData_result = sforce.connection.retrieve("SomeData__c", "Account", [parent_id]);
var SomeData = get_SomeData_result[0].SomeData__c;

alert(SomeData);
// you now have a javascript variable with the foreign data you wanted.
   

 
Sean