0

I expected the following query is valid:

SELECT ID, Subject, Type, (SELECT Field, OldValue, NewValue FROM CaseHistories)
FROM Case

But I get Didn't understand relationship 'CaseHistories' error. I can query SELECT Field, OldValue, NewValue FROM CaseHistories in a separate request.

Is this possible to retrieve cases and their histories in one query?

1

1 Answer 1

7

The child history relationship name is called "histories".
Try the following query:

SELECT ID, Subject, Type, (SELECT Field, OldValue, NewValue FROM Histories)
FROM Case
3
  • thanks Mark, where can I find how specific relationship is called?
    – edelrabe
    May 11, 2016 at 9:51
  • 1
    I found Relationship Name in Force.com IDE, is there any other tool where I can quick check the name? Maybe I can find it in Salesforce UI? Salesforce Schema Builder doesn't have one.
    – edelrabe
    May 11, 2016 at 9:54
  • 1
    You can identify parent-child relationships by viewing Entity Relationship Diagrams (ERD) or by examining the enterprise WSDL for your organization. But probably the most reliable method for identifying relationships is to execute a describeSObjects() call. You can use the AJAX Toolkit to quickly execute test calls. May 11, 2016 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .