I have written below query in Javascript(Visualforce page) and trying to access query result as shown below, but it is failing at second console log and giving error in developer console.
var user_query = "Select Id, contact.account.Name From User WHERE Id='" + user.userId + "' LIMIT 1";
var userQuery = sforce.connection.query(user_query);
var usrResult = userQuery.getArray('records')[0];
console.log('Working1***'+usrResult);
console.log('Working2***'+usrResult.contact.account.Name);
And below is the output from developer console.
Working1***{type:'User', Id:'00550000002pvqOAAQ', Contact:{type:'Contact', Id:null, Account:{type:'Account', Id:null, Name:'RUCKUS TEST VAR1', }, }, }
SCRIPT5007: Unable to get property 'account' of undefined or null reference
Is there something I am missing while rendering Account name