after creating a search and using the below timeb...
# suitescript
r
after creating a search and using the below timebillSearchObj.run().each(function(result){ } I am getting search objects and to access the column headings, I can use result.columns[k].name But how to access the data inside each of the column? this is one of the object
Copy code
result ={
  "recordType":"timebill",
    "id":"9999",
    "values":{
        "internalid":[{"value":"1105","text":"1105"}],
        "employee":[{"value":"200000","text":"xyz"}],

        "rate":".00",
        "timeSheet.startdate":"07/26/2020",
        "approvalstatus":[{"value":"1","text":"Open"}],
        "hours":"7:41"}};
Not able to parse through the object like we can parse a json object normally. Unsure what is the difference between this netsuite search object and a normal json,
c
result.getValue('fieldname')
as you would for any other record. Don't understand why you're thinking in JSON
r
thank you, bit new and learning how things work in netsuite basically.
c
It's ok. It's natural to dump objects in the console and use JSON.stringify all over the place 😄
r
one last thing I am able to get field/column names with this column_name=result.columns[k].name and to get the field values i am using this result.getValue(column_name) Issue is i am getting value of all the fields beside the
Copy code
timeSheet.startdate
result.getValue('fieldname') in field name how can i get the startdate field id? tried putting both "startdate" and "timeSheet.startdate" as fieldname
b
netsuite represents joins by separating the join id from the column id using a period
r
what will exactly be the field for startdate column?
b
the parameters to getValue are the same as createColumn
you can even use the actual column using Result.getValue(column)
r
result.getValue("employee"); is giving me the result for the employee column But for start date, I have tried all these result.getValue("startdate"); result.getValue("timeSheet-startdate"); result.getValue("timeSheet.startdate"); result.getValue("timesheet.startdate"); none of them is working
b
read my responses closer and go through the documentation i linked
r
ok
c
We could just give you the answer, but you need to learn how to learn
r
figured it out, thank you I was using the join parameter before too but it was throwing an error for some reason. started working now.