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
swapna muthiyaluswapna muthiyalu 

select field,oldvalue,newvalue,contactid,, FROM contacthistory . i tried this query to fetch account name without using nested query, but throwing error.please help

i want to fetch account name from this query.
Raj VakatiRaj Vakati
Try this SOQL 
select field,oldvalue,newvalue,contactid, ,contact.Account.Name FROM contacthistory

swapna muthiyaluswapna muthiyalu
Thanks Raj, but is is giving [object,object] as output. i want the Account name in the result.
Raj VakatiRaj Vakati
Its a salesforce way of returning .. 
You can do some think like this 

1 . Create a formual field on contact that will return the name of account 
Formual : Account.Name
2. Use this SOQL as shown below 
contact.Acc_Name__c  is formula 
select field,oldvalue,newvalue,contactid, ,contact.Acc_Name__c FROM contacthistory

Ajay K DubediAjay K Dubedi
Hi Swapna,
(a)-IF contacthistory is the child of both Account and Contact. You can query without nested query.
(b)-IF contacthistory is the custom object you can use contacthistory__c.

Please check below url to understand Prent to child query and Child to Parent query.



Please let me know if you have any query.
Please mark it as best Answer if you find it helpful.

Thank You
Ajay Dubedi