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
NewToSFNewToSF 

Look for Contact on ContactId.

Hi,
 
Here is my code. I have Custom__c object which has Admin person lookup to contacts. I need to find out the details of that contact. So I tried to use this query.
 
var c = sforce.connection.query("SELECT ID, Name  from Contact WHERE Contact.Id = '{!Custom__c.Primary_ContactId__c}'");
didn't return any records.
 
 So I tried this to check if Id's are same -
 
 var c = sforce.connection.query("SELECT ID, Name from Contact WHERE Contact.Name = '{!Custom__c.Primary_Contact__c}'");
var records = c.getArray("records");
alert(records[0].Id);
alert('{!Custom__c.Primary_ContactId__c}');

first alert i m getting is  - 0033000000ob70wAAB
and second - 0033000000ob75A
 
Why am I getting different ID's for same contact?
 
So what should I do to get the detail about Contacts from my custom object?
 
Thanks

jrotensteinjrotenstein
Perhaps you are getting back multiple records, so you should check records[1], etc and not just records[0]?

What happens if you try to display the user directly?

Code:
https://na1.salesforce.com/0033000000ob75A

 

NewToSFNewToSF
Hi,
 
  I don't want to get multiple records back, thats why I want to search on Contact Id and not on contact name.
If I directly look for https://tapp0.salesforce.com/0033000000Ob75A I get the contact detail information under contacts tab.
Is it so hard to find one user in contacts object on ID?
SuperfellSuperfell
your first query should be select id, name from contact where id = '....' and should work fine.