A question about the `search.Column` object. I was...
# suitescript
b
A question about the
search.Column
object. I was hoping to do an operation on all columns of a search result that have the type
datetime
. It seems that this property is only visible in the debugger but not actually accessible in any way (the docs don't acknowledge its existence). Am I out of luck? What I'm trying to accomplish is to format all datetime fields into a different time zone but I'm not sure how to pick out the columns that are actually a datetime. Any suggestions on how to accomplish this?
a
NetSuite search results(columns) will return text(string) most of the time(if not always). You have a couple of options: • Create an array/list of column IDs with the columns you know are going to be holding dates.(This is not good if you want this to be dynamic and you don't know the IDs beforehand.) • Add a custom label to the columns and use that as an identifier(columns will have
.name
and .
label
properties). • Dynamically determine if the value of a column is a valid date string (moment("12/20/2023", "MM/DD/YYYY", true).isValid(); // true)
b
@alien4u Cheers. I need it to be dynamic, so I guess the only thing I can do is to pattern match the value (your 3rd option). I can't wrap my head around such an inconvenient limitation to hide the column types...
b
use the .toJSON method to output the same object used by logs and the debugger
āœ… 1
šŸ™Œ 1
b
@battk Awesome, that works! Good to know! šŸ™‚ Edit: A bit of an ugly solution, but this worked for me:
Copy code
JSON.parse(JSON.stringify(column))