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
GrantMGrantM 

Retrieve contactid from User

Hi
 
I am trying to retrieve the contact a logged in user is attached to.
When querying through the API Explorer, i can retrieve the details i require:
Select Id, ContactId From User WHERE Id = '[LOGGED_IN_ID]'
However, trying this in an s-Control returns a null queryResult
SearchString="Select Id, ContactId From User WHERE Id = {!$User.Id}";
var queryResult = sforceClient.Query(SearchString);
Removing ContactId out of that query fixes the issue.
 
How can i retrieve the ContactId attached to a user account that is currently logged in through an S-Control?
DevAngelDevAngel
I don't think contact id is a field on the user object.

There is a contact id on the SelfServiceUser object.  Is this what you are trying to do?

Select Id, ContactId From SelfServiceUser Where Id = '<id of logged in user>'


Message Edited by DevAngel on 05-15-2007 09:52 AM

GrantMGrantM
Hi DevAngel
 
Thanks for your quick response.
User actually does contain a Contact Id, but it seems only a Customer Portal User.
(Maybe it's a custom field we added, i'm not 100% sure)
 
When I view the the User object in the API Explorer, i can see ContactId and query against it.
 
I think i've realise that this field is not accessible to a Customer Portal user and that is our issue.
What we've managed to do is something as simple as "Select Name from Asset",
and this returns only the Assets the Customer Portal User can see.
 
This works well for us, and i'm sure a closer view at field accesibility options will reveal why I could not access that field.
 
Thanks again for your help