I am trying to populate a DATETIMETZ sublist colum...
# suitescript
s
I am trying to populate a DATETIMETZ sublist column in a suietlet, but when trying to set the value using both a String or Date, I am getting and INVALID_FLD_VALUE error. Has anyone had success with this?
b
what does your code setting the field look like
s
Copy code
var myDate = supportcaseSearchResults[i].getValue(supportcaseSearchObj.columns[9]);
                                var parsedDate = format.parse({
                                    value: myDate,
                                    type: format.Type.DATETIME
                                });
                                sublist.setSublistValue({
                                    id: 'custpage_sublist_message_date',
                                    line: lineNum,
                                    value: parsedDate
                                });
@battk
b
whats the value of myDate
s
9/27/2018 8:40 am
and after its parsed its: 2018-09-27T134000.000Z
I realize the time is wrong in the parsed value, but thats ok
@battk
b
your datetimetz wants seconds in the string
Copy code
var dateString = supportcaseSearchResults[i].getValue(supportcaseSearchObj.columns[9]);
    var parsedDate = format.parse({
      value: dateString,
      type: format.Type.DATETIME
    });
    var formattedDate = format.format({
      value: parsedDate,
      type: format.Type.DATETIMETZ
    });
    sublist.setSublistValue({
      id: "custpage_sublist_message_date",
      line: lineNum,
      value: formattedDate
    });
s
@battk, thank you that worked.
I was hoping the sublist would properly sort the data if the column type was date/time instead of a string, but looks like it doesn't. Either way though, thanks for helping me get this working