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
Kseniya BogoslavskayaKseniya Bogoslavskaya 

simple salesforce IndexError: list index out of range with bulk API

I am trying to pull the data from `Opportunity` object in SalesForce using bulk API. My query looks like this:

```
opportunity = sf.bulk.Opportunity.query('SELECT Id, Name, LeadSource, Probability from Opportunity')
print(opportunity)
```
It does return the data with no issues, however, if I want to select more columns it gives me:

```
IndexError: list index out of range
```
Help! 
Andrew GAndrew G
When performing a SELECT statement on an object, a LIST of records is returned, unless you explicitly LIMIT the return to 1.
 
List<Opportunity> opportunities = new List<Opportunity>();

opportunities = sf.bulk.Opportunity.query('SELECT Id, Name, LeadSource, Probability from Opportunity');

for( Opportunity opp : opportunities ) {
    System.debug('***debug : ' + opp.Name);
}

//OR

for (Integer i = 0; i < opportunities.size(); i++) {
    System.debug('***debug : ' + opportunities[i].Name);
}

Regards
Andrew


Note:  code is not compiled and is supplied as is , so there is no guaretee on syntax
Kseniya BogoslavskayaKseniya Bogoslavskaya
Hi Andrew,
I am using `simple salesforce` library with Python. Do you happen to have a solution with Python? 

Thank you for your answer!
Andrew GAndrew G
Context always helps

Bulk Query doesn't check for compound fields (https://github.com/simple-salesforce/simple-salesforce/issues/182)
reference:
https://github.com/simple-salesforce/simple-salesforce/issues/182

Are you trying to query a compound field like Address? 

Regards
Andrew