0

I am trying to query Salesforce opportunities from another Salesforce org using the Query API

I am setting the following query in the endpoint method

request.setEndpoint('callout:'+namedCredential+'/services/data/v56.0/query?q=select+Id,+Name,+Amount+from+Opportunity+where+Brand__c+in+('+brandIdString+')');

Now, the above query works fine and returns all the required Opportunities.

However, now what happens is that if I try to add any relational field in the query, it fails. e.g. the below request fails

request.setEndpoint('callout:'+namedCredential+'/services/data/v56.0/query?q=select+Id,+Name,+Amount,+Brand__r.Address__c+from+Opportunity+where+Brand__c+in+('+brandIdString+')');

Is the above not possible? If not are there any alternatives for the same?

I am getting the following message in the debug log enter image description here

6
  • 2
    Please edit your post and include the error message. Nov 22, 2022 at 22:18
  • it looks like you are missing a comma between Amount and Brand__r Nov 22, 2022 at 22:42
  • @DanielHoechst, actually I have the comma in my code. It was a miss while posting.
    – Madhurima
    Nov 22, 2022 at 23:44
  • If no error, by any chance are you using system.debug(results) to display the resulting values? if so, system.debug will not display parent field values of sobjects. The values are there, but must be explicitly enumerated in a debug statement
    – cropredy
    Nov 23, 2022 at 18:01
  • @cropredy I have added the error message that \i am getting in the debug log
    – Madhurima
    Nov 23, 2022 at 18:58

0

You must log in to answer this question.

Browse other questions tagged .