Andre's Blog

Personal blog of Andre Perusse

Fields Not Updating When Using Salesforce API with .NET / C#

I just spent the last few hours tearing my hair out trying to determine why a Contact record in Salesforce wasn't being updated from their API. I had successfully created the record using Visual Studio to generate a series of proxy classes from Salesforce's WSDL file, but subsequent updates didn't appear to be working at all even though the API reported a successful update transaction.

It turns out that all the fields I was trying to update were non-string fields. A few of them were Boolean fields (true/false), some were number fields, and others were date fields. Apparently, when using .NET, you have to explicitly tell Salesforce that you've changed the value of any non-string field by using the associated "Specified" field, like so:

myContactRecord.CustomDateField__c = DateTime.Now;
myContactRecord.CustomDateField__cSpecified = true;

A thousand thank-you's to fine fellow (RobD) who answered this question on StackOverflow.

Comments (1) -

  • Rachel

    5/1/2019 5:57:18 PM |

    This is old, but I still wanted to say thank you for sharing your solution and keeping it online. I've also been pulling my hair out for quite awhile with the same issue and was amazed the problem was so simple!

Loading