I want to include User.UserName and Network.Name in a LoginHistory SOQL query (e.g. SELECT Id, User.UserName, Network.NetworkName FROM LoginHistory), but the system doesn't "understand" either relationship. Can anyone confirm this limitation? It will be annoying to have to write two more queries for user and network fields.

I tried to run Developer Workbench to examine further but it is not working right now (DNS address could not be found).

1 Answer 1


Like English language, there are more exceptions than rules in Salesforce :) Not being able to do parent reference query on Parent fields sometimes is one of them.

Salesforce typically populates "relationshipName" on reference fields which are traversable. For LoginHistory, user object doesn't have that relationship name (as you can see below). So without that, you cannot traverse.

enter image description here

Since LoginGeo has relationship name, you can traverse that using select LoginGeo.City from loginhistory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .