3

I am doing coding in Eclipse. I am using SOAP API for that.

there is method called query()

i am use following code

PartnerConnection connection = ForceConnection.getOrgConnection();
List<SObject> objects = new ArrayList<SObject>();
QueryResult queryResults = connection.query("select name from book__c");
for (int i=0;i<queryResults.getRecords().length;i++) {
                SObject so = (SObject)queryResults.getRecords()[i];
                objects.add(so);
            }

while update

SObject[] sObjArray = new SObject[objects.size()];
objects.toArray(sObjArray);
SaveResult[] upsertResults = connection.update(sObjArray);

getting Error

Id not specified in an update call' status Code='MISSING_ARGUMENT

while I am change the query with

select id,name from book__c

getting Error

Duplicate ID found

Please any one has Idea..Guide me...

  • 1
    Issue should be in your "SObject[] sObjArray = new SObject[objects.size()]; objects.toArray(sObjArray); SaveResult[] upsertResults = connection.update(sObjArray);" Change SObject[] to List<Sobject> and use sObjArray.addall(Objects) – A-d Sep 10 '14 at 12:56
  • Issue is not in update Syntax... Issue is while select Query is fire without ID parameter id=null and while select Query with ID parameter ID is come 2 times... – Chintan Sep 11 '14 at 6:39
3

There is no solution for that in SOAP API used with Partner WSDL. This is an idea in a salesforce site.

Please refer to the following links:

I also have a solution, but it is not logic (use if required)

PartnerConnection connection = ForceConnection.getOrgConnection();
List<SObject> objects = new ArrayList<SObject>();
QueryResult queryResults = connection.query("select Id,name from book__c");

for (int i=0;i<queryResults.getRecords().length;i++) {
    SObject so = (SObject)queryResults.getRecords()[i];
    so.removeField("Id");
    objects.add(so);
}

Note

  1. There are 2 times Id was come in the Sobject.
  2. It means there are 2 fields as name Id
  3. so remove 1 field of id from the object
  4. using the the following line

    so.removeField("Id");
    
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.