• Wei Cheng Hsu 9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Account has a field `Source_System__c` as its parent.

I wanna query Name, Id from Source_System

This query is workable. 
[SELECT Source_System__r.Name, Source_System__r.Id from Account]

However, I wanna have the value from Source_System can be nested in a object.
Like the sub-query's result. But it didn't work.



    SELECT (SELECT Name, Id from Source_System) FROM Account
                             ^
ERROR at Row:1:Column:30
Didn't understand relationship 'Source_System' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.



    SELECT (SELECT Name, Id from Source_System__r) FROM Account
                             ^
ERROR at Row:1:Column:30
Didn't understand relationship 'Source_System__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Make JSON response can have __c __r in the suffix for the keys.

My expecting JSON response is

    {
        name: "test",
        Parties__c: {
            ~~~
        },
        Queue__c: {
            ~~~
        }
    }

However I got `Incompatible types since an instance of Id is never an instance of Queue__c`

I know I could not have "__c", "__r" as variable names.

But I have to. Please give me some ideas to workaround this situation.

Thanks

        global class SearchResponse {
            public PartyField Parties__c;
            public QueueContract Queue__c;
            ....