I need a rubber duck.. ``` var date...
# suitescript
t
I need a rubber duck..
Copy code
var dateObj = new Date(fldObj.value);
                var parsedDate = format.format({
                    value: dateObj,
                    type: format.Type.DATE
                });
                log.audit("setValue:fldObj.date", JSON.stringify({ fldObj, dateObj, parsedDate }));
                rec.setValue({
                    fieldId: fldId,
                    value: parsedDate
                });
log.audit:
Copy code
{
   fldObj: {
      type: "date",
      value: 952156800000
   },
   dateObj: "2000-03-04T08:00:00.000Z",
   parsedDate: "2000-03-04"
}
caught error...
Copy code
{
   fldId: "birthdate",
   e: {
      type: "error.SuiteScriptError",
      name: "INVALID_FLD_VALUE",
      message: "Invalid date value (must be YYYY-MM-DD)",
      id: "",
      notifyOff: false,
      userFacing: true
   }
}
b
use setValue with the Date as the value use setText with a string as the text
1
t
thanks @battk