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
Milan Tomic 14Milan Tomic 14 

SOAPI API: INVALID_TYPE: Must send a concrete entity type

Hi

While executing this code:

Task[] records = new Task[5];

            QueryResult queryResults = connection.query("SELECT Id, Subject, Description FROM Task LIMIT 5");
            if (queryResults.getSize() > 0) {
                for (int i = 0; i < queryResults.getRecords().length; i++) {
                    Task d = (Task) queryResults.getRecords()[i];
                    d.setDescription(d.getDescription() + " -- UPDATED");
                    records[i] = d;
                }
            }

            // update the records in Salesforce.com
            SaveResult[] saveResults = connection.update(records);

I got this error:

[InvalidSObjectFault [ApiQueryFault [ApiFault  exceptionCode='INVALID_TYPE'
 exceptionMessage='Must send a concrete entity type.'
]
 row='-1'
 column='-1'
]
]

Any idea what could be wrong? :)
Best Answer chosen by Milan Tomic 14
Daniel BallingerDaniel Ballinger
I'm not sure what language you are using, Java maybe? The problem it likely around the Array of records that is passed to the update call. You should only pass in records that actually need an update.

If there aren't 5 records that need an update you are likely passing in an array with null elements. E.g. Think about what would happen if there is only one Task in Salesforce that matches your SOQL query.

Try making a new collection of records to hold the records that need an update an only pass those over.

All Answers

R Z KhanR Z Khan
Hi Milan,

this does not seem to be an apex code. This code should work for oyu
Lisst<Task> records = new <Task>();

    List<Task> queryResults = (List<Task>)Database.query('SELECT Id, Subject, Description FROM Task LIMIT 5');
    if (queryResults.size() > 0) {
        for (Task d:queryResults) {
            d.description=d.description + ' -- UPDATED';
            records.add(d);
        }
    }
update records;

 
Daniel BallingerDaniel Ballinger
I'm not sure what language you are using, Java maybe? The problem it likely around the Array of records that is passed to the update call. You should only pass in records that actually need an update.

If there aren't 5 records that need an update you are likely passing in an array with null elements. E.g. Think about what would happen if there is only one Task in Salesforce that matches your SOQL query.

Try making a new collection of records to hold the records that need an update an only pass those over.
This was selected as the best answer
R Z KhanR Z Khan
List<Task> queryResults =[SELECT Id, Subject, Description FROM Task LIMIT 5];
        for (Task d:queryResults) {
            d.description=d.description + ' -- UPDATED';
        }
update queryResults;
Actually cosndierign you are utdating the same records you dont even need ot tracka  separate list. The code above will do the same thing. 
Milan Tomic 14Milan Tomic 14
Daniel Ballinger, you are a genious! :)

Yes, I did not had 5 elements in array but only 1 or 2. Creating a new array just before connection.update(records) call, solved a problem :)

records = Arrays.copyOf(records, queryResults.getSize());