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
somasoma 

Some values not being maintained during upsert

I'm not sure if this is an upsert issue or if I am simply not setting a variable to a proper value, but after a successful upsert, the checkbox field does not appear to be checked if I set it to true. I have an object "Object__c" which has a checkbox field "Checkbox__c" and an ID field "Id", and I set the checkbox in the following way:

Object__c myObj = new Object__c[1];

if (somethingIsTrue)
    myObj[0].Checkbox__c = true;
else
    myObj[0].Checkbox__c = false;

Then I upsert:

if (sfdc.upsert("Id", myObj)[0].success)
    // yay!

This is all pretty standard, so I don't know why the checkbox isn't checked if set to true, but I'm wondering if I should be setting it to the literal string "true" or the numerical value 1 instead of the boolean value "true". Any ideas?

SuperfellSuperfell
You have to set the specified property as well, to tell the .NET soap stack that you've set the property otherwise it doesn't include it in the request.

myObj[0].Checkbox__c = true;
myObj[0].Checkbox__cSpecified = true;
somasoma
I had a feeling this was the case. Is this necessary for checkboxes, only?.

Can you point me to the documentation that discusses this? I've been through documentation several times looking for something that discussed the "Specified" flag and I never found it.

Message Edited by soma on 11-13-2007 03:45 PM

SuperfellSuperfell
All properties that are not of type string.

You won't find it in the salesforce.com API docs, because its nothing to do with us, its a "feature" of the .NET SOAP Stack, you'll need to trawl the .NET docs.
somasoma
Thanks a lot for your reply. I'm quite sure this is the issue. I never thought it to be a .NET-specific "feature." How silly.