I've been trying to list opportunities in my account. There are only two opportunities created by me in salesforce. But while listing the same, more than 30 are shown in the list. I tried to filter using different methods(like by OwnerId and so). But none seems working.


query = "SELECT Id, Name, AccountId FROM Opportunity"
    fileList = ""
    fileList = sf_api_call('/services/data/v40.0/query/', {'q': query})
    i =0
    for x in fileList['records']:
        folId = fileList['records'][i]["Id"]
        folName = fileList['records'][i]["Name"]
        AccountId = fileList['records'][i]["AccountId"]
        i +=1

Any solutions??

  • This query definitely gets everything. You need to show an example of a query using a filter. – sfdcfox Feb 27 at 5:23
  • Visibility and ownership are very different, and they're also distinct from opportunities associated with an account. Your query will return the opportunities you can see, not those you own. Could you please try to clarify what you are aiming to achieve? – David Reed Feb 27 at 5:25
  • Hi @DavidReed, Thank you for the response. I actually created two opportunities and I need to list only those two using query. But while using the above query, many opportunities are listed. I also tried using - WHERE CreatedById = 'id'. Still its listing all the opportunities. – user79515 Feb 27 at 6:15
  • Hi @sfdcfox, I tried using query = "SELECT Id, Name, AccountId FROM Opportunity WHERE CreatedById =myId " Still its showing all the opportunities – user79515 Feb 27 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.