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
David Jenkins 31David Jenkins 31 

SOQL to get Live accounts / how to locate columns

Hi there,
I'm trying to return just the live Accounts through SOQL but when I attach status to the where clause it errors, is the Status column in the accounts table or do i need to join to another table? Whats the best way to find the whole schema?

Thank you

Dave.
 
Best Answer chosen by David Jenkins 31
Ravi Dutt SharmaRavi Dutt Sharma
David,

If status is a custom field, then use it as Status__c in the SOQL query.

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
Hi David,

Try using Schema builder present in the org. Go to Setup, in the Quick Find box, type Schema Builder.
David Jenkins 31David Jenkins 31
Awesome! That's brilliant. I'm confused then because the Status field is in the account table. 

However, doing either of the below errors, to me they're good SOQL queries:
SELECT id FROM Account WHERE Status = 'Live'

Or
SELECT id FROM Account WHERE Status IN ('Live')


 
David Jenkins 31David Jenkins 31
Sorry I should I'm query it through the rest API. I quickly nipped in reports to see what returned in there and I can see that its attributed to Account: Custom Info. I can see the status in Account in the schema.I think I missing something obvious here!
Ravi Dutt SharmaRavi Dutt Sharma
David,

If status is a custom field, then use it as Status__c in the SOQL query.
This was selected as the best answer
David Jenkins 31David Jenkins 31
Thank you Ravi, that's spot on. Now you've said it that makes perfect sense.