Accessing Salesforce Record Fields with JavaScript
I wanted to share with you a utility function that I’ve created and stored in my Static Resources. I’m using this function to dynamically access fields from JavaScript objects that represent Salesforce records obtained by sforce.connection.query or Remote Action. Here’s the function below:
Sample use:
I’ve found this method to be incredibly useful when I have to work with hierarchy of objects returned from Salesforce (e.g. - record.Order_Line__r.Primary_Site__r.Street_Addess__c). I hope that you’ll find this useful as well.