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
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();
or
Double d = mysobject.getAmount();

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

Thanks
ChitraChitra
Hello....

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..


Thanks,
chitra

               
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

Thanks

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
e.printStackTrace();
}
return null;
}
}
return null;
}