+ Start a Discussion
Federico LarsenFederico Larsen 

Partner API, easy one

Hi, I am new with de partner API.
I have this basic problem, with the Enterprise API, I am used to do for example, Boolean b = mysobject.getMyBooleanField__c();
Double d = mysobject.getAmount();

but in the partner API, how do I get de Deserialized Values?


For more info.. please look at the partner samples..

    SObject oSObject = (SObject)records[i]; // From the query...
    MessageElement fields[]= oSObject.get_any(); // returns an array of MessageElements...
    String email =fields[0].getValue(); // Array contains the value of the fields queried..


Federico LarsenFederico Larsen
Thanks for your reply, but for a String value I can use the getValue() method, my question is for non-string values, like Double, Date, Calendar, Boolean


I am temporay using this static method, untill I found, or someone tell me the rigth way to do it. It is based on the getFieldValue of the PartnerSamples70.

public static Object getFieldObjectValue(MessageElement[] value, String name, String type) {
for (int i = 0; i < value.length; i++) {
if (value[i].getName().toLowerCase().equals(name.toLowerCase())){
try {
MessageElement msg = value[i];
if (type.toLowerCase().equals("boolean")){
return msg.getObjectValue(Boolean.class);
if (type.toLowerCase().equals("double")){
return msg.getObjectValue(Double.class);
if (type.toLowerCase().equals("date")){
return msg.getObjectValue(Date.class);
if (type.toLowerCase().equals("calendar")){
return msg.getObjectValue(Calendar.class);
if (type.toLowerCase().equals("int")){
return msg.getObjectValue(Integer.class);
return msg.getValue();

} catch (Exception e) {
// TODO Auto-generated catch block
return null;
return null;