+ Start a Discussion
Jonathan Osgood 3Jonathan Osgood 3 

SOQL query on User Object

Hi,

I am unable to access certain owner fields on the user object. I'm trying to reach the standard AccountID field and a custom field with no luck. I can reach Owner.name without a problem though. 

This works: 
SELECT ID, owner.Name FROM Publication__c

 and this works:
SELECT ID, owner.email FROM Publication__c

BUT this will NOT work:

SELECT ID, owner.AccountID FROM Publication__c

Is this a known limitation?
Harish RamachandruniHarish Ramachandruni
Hi ,

Is their any relation b/w Account And Publication__c 

what  is relation and which is parent and what is child  .

I will give a solution for you if you clarify above relation 


Regards ,
Harish.R
 
Jonathan Osgood 3Jonathan Osgood 3
Hi Harish,

Yes, there is a look up on Publication__c (child) to Account (parent). I have a trigger that will populate the Account lookup on publication__c when a publication record is updated. The Account ID is on the User record who is updating the publication. 
Harish RamachandruniHarish Ramachandruni
Hi

SELECT ID, Account.owner.id  FROM Publication__c.



Check this one 


Regards,
harish.r
 
Harish RamachandruniHarish Ramachandruni
SELECT ID, (Lookup filed api name ).owner.id  FROM Publication__c.
 
Jonathan Osgood 3Jonathan Osgood 3
Thanks Harish,

This does not work because the look up field will not be populated yet. This is the field the trigger is going to populate with the User Account ID.

The query needs to be something like SELECT ID, owner.AccountID FROM Publication__c but that doesnt not work. There may be limitations as to what fields you can access on the User object.
Harish RamachandruniHarish Ramachandruni
Hi ,

Is their any relation b/w user and account . We can Query data crom chaid to parent filed . 


Regards ,

Harish.R.