DEV Community

Rachel Soderberg
Rachel Soderberg

Posted on • Edited on

2 1

Salesforce Fields Not Updating With C# Web Service

This week I made a silly discovery while I built out some new functionality for the Salesforce Asset Updater application I've been assigned to create at work. I'm hoping that by sharing this discovery here, I can save someone else the time sink of trying to figure out why their fields won't update!

Salesforce has a number of different field types that can be used on each object. These range from the simplest text type fields all the way up to more complex lookup fields with relationships to other objects. Non-text fields such as Number, Checkbox, Date, and Picklist require a very simple but essential extra step during object initialization to indicate to Salesforce that a change must be made to these fields.

As a reminder, typical Salesforce object initialization for update and creation with only string fields looks like:

Account newAccount = new Account{
    Id = GetSalesforceId(custName),
    Phone_Number__c = custPhone,
    Shipping_Address__c = custAddress,
}

Once you attempt to create or update fields that are of a non-string type (such as a Checkbox), you must provide the desired field value and also update the field's "specified" field as seen in the example below:

Account newAccount = new Account{
    Id = GetSalesforceId(custName),
    Phone_Number__c = custPhone,
    Shipping_Address__c = custAddress,
    /*Updating Checkbox field below*/
    Is_Premium_Customer__c = true,
    Is_Premium_Customer__cSpecified = true
}

There is no clear exception or error output letting you know you've forgotten this crucial step. The only indication that you've attempted to modify one of these special fields without including the specified field is the field just refusing to update without any complaints. Personally, I spent almost an hour trying to figure out where I went wrong before the right google search finally led me down a path to this solution.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay