1

The documentation on using the partner WSDL says there's an SObject.getField("FieldName"); method. I don't see it.

I saw an example with the two lines that are commented out below. Those lines will not compile as SObject does not have a getField() method.

Anyone know how to get field values out of objects returned by the partner API?

QueryResult qr = stub.query(soqlQuery);
SObject[] recordList = qr.getRecords();

for (int i = 0; i < recordList.length; i++) {
    SObject contact = recordList[i];
    //Object firstName = contact.getField("FirstName");
    //Object lastName = contact.getField("LastName");   
}
1
  • Can you also provide the link for the documentation which you are referring in your question? Very recently have been observing quite a few documentation issues, so that may be one of that.
    – Jayant Das
    Commented Sep 28, 2018 at 0:03

1 Answer 1

0

It is not getField method but get(Field) method.

Example:

Account acc = new account(Name = 'Acme', Description = 'Acme Account');
String description = (String)acc.get(Schema.Account.Description);
System.assertEquals('Acme Account', description);

And in your case you are looking for get(fieldName) method.

Example:

Account acc = new account(Name = 'Acme', Description = 'Acme Account');
String description = (String)acc.get('Description');
System.assertEquals('Acme Account', description);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .