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
JesipJesip 

AJAX Date Format

I am using the new sForce AJAX toolkit to create a new object.  I would like to default a date field on the object, but I keep getting an error when doing the set.  Can anyone tell me what the valid date format would be in this case?

Opp.set("CloseDate", doDateConversion());

 

function doDateConversion() {

var d = new Date();

var curr_date = d.getDate();

var curr_month = d.getMonth() + 1;

var curr_year = d.getFullYear();

var dateString = curr_year + "-" +   curr_month + "-" +   curr_date ;

return (dateString);

}

DevAngelDevAngel

Hi Jesip,

If the field you are setting is of type Date or DateTime, then you pass the set method a Date type.  So, for Opp.set try Opp.set("CloseDate", new Date());