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
PowerUserPowerUser 

UPSERT NOT WORKING!!!

I'm using C# to call the Salesforce API.  I have a custom object with many custom fields.  I instantiate my custom object, and set all of the fields, and then send an upsert command with that object.

 

Every field saves just fine...  EXCEPT THE FIELD WITH A DATETIME TYPE!!!  I don't get it.  It forces me to save a DateTime object to that field, but never saves it.

 

The upsert finishes with no errors.  And like I said before: Every field is saved EXCEPT the dateTime field.

 

What is the problem?

 

Here is the code:

 

for (int i = 0; i < data.Length; i++)
                {
                    sforce.Time__c[] time = new Time__c[1];
                    time[0] = new sforce.Time__c();

                    Dictionary<string, Object> dataRow = (Dictionary<string, Object>)data[i];
                    foreach (KeyValuePair<string, Object> dataEntry in dataRow)
                    {
                            time[0].id__c = Convert.ToString(dataEntry.Value);

 

 // HERE IS WHERE IS SET THE DATETIME.  IT GETS STORED HERE, BUT NEVER SAVED AFTER UPSERT

                            time[0].date__c = Convert.ToDateTime(dataEntry.Value);
                            time[0].time__c = (string)dataEntry.Value;
                    }

 

// THE UPSERT SAVES ALL OTHER FIELDS, BUT IGNORES THE DATETIME.  NO ERRORS ON UR

                    sforce.UpsertResult ur = binding.upsert("id__c", time)[0];

}

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

All Answers

SuperfellSuperfell
This was selected as the best answer
PowerUserPowerUser
Incredible... Thanks!