+ Start a Discussion
Abhishek Sharma 527Abhishek Sharma 527 

unable to fetch records from case

Hello There, I'm trying to fetch records from Case object but it showing error as - No such column 'Contact' on entity 'Case'

my query is - 
Select id, Status, Account.Name from Case where Contact IN ('Forbes, Sean', 'Pavlova, Stella')
can anyone plz suggest if any mistake
Best Answer chosen by Abhishek Sharma 527
ravi soniravi soni
Hi Abhishek,
you can try like below.
Select id, Status,contact.Name, Account.Name from Case where Contact.Name IN ('Tim Barr', 'Tom United Oil & Gas singapore')

don't forget to mark it as the best answer.
Thank you

All Answers

PriyaPriya (Salesforce Developers) 
Hey Abhishek,

You cannot put the contact filter on Case like this in SOQL. 

So kindly refer thie example :- 

Assuming you have Checkbox field in Account as IsChecked__c and Picklist field on Contact as Status__c.
An example query to fetch cases where Account's IsChecked field is check and Contact's Status field is Started
SELECT Id, CaseNumber, Contact.Name FROM Case WHERE
    Account.IsChecked__c = true AND
    Contact.Status__c = 'Started'

For more detail refer this:- 
https://salesforce.stackexchange.com/questions/169565/fetch-contact-name-from-case
 

Kindly mark it as the best answer if it works for you.

 

Thanks & Regards,

Priya Ranjan


 
ravi soniravi soni
Hi Abhishek,
you can try like below.
Select id, Status,contact.Name, Account.Name from Case where Contact.Name IN ('Tim Barr', 'Tom United Oil & Gas singapore')

don't forget to mark it as the best answer.
Thank you
This was selected as the best answer
Abhishek Sharma 527Abhishek Sharma 527
Thanks for response Priya and Ravi, I'm not sure what is isChecked function used for, can you plz elaborate a little more on this part to get better clarity.

Regards.
Abhishek
ravi soniravi soni
HI Abhishek Sharma 527,
you just need to copy & paste below query in your query Editor and you will find data.
Select id, Status,contact.Name, Account.Name from Case where Contact.Name IN ('Forbes, Sean', 'Pavlova, Stella')

('Forbes, Sean', 'Pavlova, Stella') => this all are contact Name. you can paste here your contact name and try it. It will work.
don't forget to mark it as best answer.
Thank you 
ravi soniravi soni
HI 
Abhishek Sharma 527,
please mark it as the best answer if your query has solved.
Thank you
Abhishek Sharma 527Abhishek Sharma 527
Thanks ravi, I know your DML query would work, I want to know about isChecked field in account and it's relevance in contact object if you can help with that.