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
fruser.ax29fruser.ax29 

GetFieldsToNull() API Call

I am using version 2.5 of the SForce API. I was wondering what exactly does GetFieldsToNull API does. Can you provide more details on it.? Is it a way to get all the fields in a Object returned in QueryResult, without knowing the names of the fields.

Thanks

fruser

DevAngelDevAngel

Hi fruser,

The fieldsToNull property is used to explicitly tell the web service which fields on an update should be set to null.  Most generated web service clients do not include null values when creating a SOAP message.  This is good.  We have the ability to add up to 255 custom fields to most objects in the schema.  If you want to make an update to a single field, the message size would be needlessly large if all known fields where included in the message.  So  the proxy clients "optimize" the message content by excluding field defintions that have a null value.  This means there needs to be a mechanism by which the client can tell the web service to null a field.  Enter the fieldsToNull.  Now, a java client will create a getter and setter for each available field.  In the case of the fieldsToNull, the getter is not that useful as this property is never set by the web service, but instead is used by the client to tell the web service which fields to set to null.

Hope this was clear.

Cheers.

Michael SMichael S
please give a sample soap message that uses the fieldsToNull element
DevAngelDevAngel
What language would you prefer Boss?
Michael SMichael S

The actual SOAP XML please like chapter 8 in the sforce 2.5 API manual.

Thanks in advance,

Michael

Michael SMichael S
Please post a SOAP XML sample that shows multiple fields to null.
DevAngelDevAngel

Hi fruser,

The fieldsToNull property allows you to explicitly tell the web service to remove a value from a field.  The way most SOAP clients work is that if the value on an object is null, say the City field on an account object, that field will not be serialized and sent to the web service.  So setting a field value to null in your client code will not cause the field to be nulled on the web service.  This is where the fieldsToNull property comes in.  If you set this value to an array of strings that contain valid field names, those fields for that record will be set to null.  No other way around it. 

An SObject that recieve in a SOAP response will never have fieldsToNull, so the getFieldsToNull method is of little use, but all properties end up with getters as well as setters.  The only time you would use getFieldsToNull is when you want to retrieve the values that you set for that property either before or after you created your SObject.