2

I'm using the Enterprise WSDL in .NET and trying to run binding.update(sObject[]) on an Account record that I previously loaded through the SOAP client. Basically, I'm comparing and setting values on the sObject and then hitting update.

For some reason, if the field being updated doesn't currently have a value in Salesforce, the update call does not add a value. If I log into Salesforce and set a value first (e.g. set it to 0) then the exact same code updates the field correctly.

As far as I can tell this is only happening with custom fields that are numbers or dates, not strings (I can't cleanly verify if this is restricted to custom fields).

I'm pretty new to Salesforce so please let me know if there's an obvious detail I should have included.

4
  • What language are you using the WSDL from. With .NET I think certain fields in the Enterprise WSDL get a corresponding "HasValue" or "IsDefined" boolean property (the exact term eludes me). If it exists and this is the first time your are defining a value, try setting the corresponding boolean as well. Apr 7 '15 at 22:28
  • Sounds like you might be trying to set the field values to NULL? If so, then you have to add such fields to the "fieldsToNull" array on the sObject prior to the update call. Otherwise, fields that have null values are skipped/ignored. Apr 8 '15 at 10:01
  • @DanielBallinger Amazing! Thank you! I haven't looked up yet why these extra fields are included but there is indeed a BOOL xyzFieldSpecified which needs to be set true for the value to go to Salesforce. Apr 8 '15 at 14:03
  • @KirillYunussov Thank you for responding. I didn't know about fieldsToNull but my problem was the other way around, trying to make the value not-NULL in Salesforce. Apr 8 '15 at 14:04
1

The answer was provided by @DanielBallinger in a comment above.

The .NET WSDL includes an additional flag ending in Specified for certain fields. This needs to be set true in order for the update to take in Salesforce.

E.g.:

account.Twitter_Followers__c = 999; account.Twitter_Followers_cSpecified = true;

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.