Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I am currently writing a c# .Net application that makes use of the salesforce API. I am sending account objects with DateTime fields.

my DateTime objects are all in this format "dd/MM/yyyy HH:mm:ss" which is also the same format of the data fields that is returned when I do a simple query "SELECT Name, Date FROM Account WHERE ID != null" - I have set a date in a test account in salesforce manually prior to the query. I have checked everything that has to do with date format and I am confident that I am sending the correct datatype and DateTime format to salesforce.

My problem is Salesforce seems to leave the Date field blank. Anyone know of a way I can make sure Salesforce is accepting the date details.

DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

dtfi.FullDateTimePattern = "dd/MM/yyyy HH:mm:ss";

dtfi.DateSeparator = "/";

string _TempRangeEndDate = "2013-08-31"

DateTime objDateRangeEnd = Convert.ToDateTime(_TempRangeEndDate,dtfi);

_TempAccount.Date_End__c = objDateRangeStart; //Salesforce not accepting converted format which is "31/08/2013 00:00:00"

1 Answer

0 votes
by (32.1k points)

The .NET SOAP stack doesn't send DateTime (and some other primitive types such as numbers) without you setting the additional specified flag, e.g.

_TempAccount.Date_End__c = DateTime.Now;

_TempAccount.Date_End__c_Specified = True;

If you don't set this flag the .NET SOAP stack doesn't serialize this element and its never sent to salesforce. (and so the field basically remains blank)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories