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
InterceptTechieInterceptTechie 

User Table From S-Control

Hi Everyone,

I'm having a pretty basic problem but I hope someone can assist me with.  I've added a second lookup field to the Opportunity object called "Client_Account_NameId__c" which is related to the Account object.  This is basically the same relationship as the default "Account" field of the Opportunity object.

I'm trying to find the owner of this lookup field in an s-control and whenever I try it, my code breaks.  Below is the a snippet of the related code:

Code:
var result1 = sforce.connection.query("Select OwnerId from Account where Id ='{!Opportunity.Client_Account_NameId__c}'");
var records1 = result1.getArray("records");

var result2 = sforce.connection.query("Select FirstName, LastName from User where Id =records5[0].OwnerId");
var records2 = result2.getArray("records");

var owner = records2[0].FirstName + " " + records2[0].LastName;

 
I'm able to get back the OwnerId but I can't seem to test if any data is being collected from the User table.  I've also tried $User because that was used in other examples I've found but that didn't work either.

I'm positive this is not the best approach to get this data either so any suggestions are welcome.

Thanks alot for your help

CaptainObviousCaptainObvious
try:
 
var result2 = sforce.connection.query("Select FirstName, LastName from User where Id ='" + records1[0].OwnerId + "'");
 
InterceptTechieInterceptTechie
Thanks CaptainObvious.  It worked! :)  The 'records5' was a typo by me but the other syntax you added did the trick.