What have you tried?
# suitescript
e
What have you tried?
n
getValue, dot notation, non dot notation.. clearly im doing something wrong though!
s
[0].values["propname"].value
or
.text
e
Assuming that Array is stored as `data`:
Copy code
data[0] // <= It's an Array with one Object element

data[0].recordType // <= "job"

data[0].values // <= the nested Object with the Columns

data[0].values["customer.internalid"] // <= must use bracket syntax because NetSuite put that stupid . in the property name

data[0].values["customer.internalid"][0] // <= Select Columns manifest as Arrays

data[0].values["customer.internalid"][0].value // <= "850"
s
actually, how did you get the object in this format,
toJSON()
on the result I guess?
n
so this works:
jobres[0].id
but
jobres[0].values.custentitycert_billing_uom.text
does not - I have a function that returns a search result (I did not put toJSON())
e
because
custentitycert_billing_uom
is an Array
not an Object
n
Copy code
jobres[0].values.custentitycert_billing_uom[0].text
I tried that as well ^
s
all select/multislect fields come back as array
If you are not
toJSON()
this then the object might just be printing like this, and you need to use the actual search call
getValue()
e
Right.
n
i tried getValue as well... didn't seem to work though.. not sure why
b
you probably want to be more specific with your error messages
e
Please show the rest of the code where you're trying to read the result data
n
there are no actual error messages, it just doesn't print the log
s
Can you give larger context, like maybe the codeblock where you are trying to read from this object? Are you doing in the
.each()
call?
n
Copy code
function getProjectInformation(project) {
      var jobSearchObj = search.create({
        type: "job",
        filters: [
          ["entityid", "contains", project]
        ],
        columns: [
          search.createColumn({
            name: "internalid",
            join: "customer",
            label: "Customer Internal ID"
          }),
          search.createColumn({
            name: "custentitycert_billing_uom",
            label: "Invoice Billing Unit of Measure"
          })
        ]
      });

      var projectdata = jobSearchObj.run().getRange(0,999);

      return projectdata;
    }
  }
so this is what feeds the results
e
Surround with three backticks for codeblocks, or use the Lightning Bolt > Insert Text Snippet
Copy code
var results = getProjectInformation(data);
results[0].getValue({name: "custentitycert_billing_uom"});
results[0].getValue({name: "internalid", join: "customer"});
n
Copy code
var billingtype = jobres[0].getValue({fieldId:'custentitycert_billing_uom'});
    log.debug('billingtype',billingtype);
I am just trying to put the field value into a variable and print.. no error message it just doesn't print anything
e
It's
name
, not
fieldId
n
aha... i think it's name...
ah man
s
I would personally do the building and processing the lines to a desired format in the same function as well and make use of the
.each()
or
runPaged()
if you expect a lot of resutls
n
good call Sandii
thank you for bearing with me / helping me as I learn this stuff... I really enjoy it !
s
eric has a general format he uses that he posts here pretty freuquently
b
projectdata is an array of search.Result, if you try to log it, it will log something like what you hard earlier
Copy code
[
   {
      recordType: "job",
      id: "861",
      values: {
         "customer.internalid": [
            {
               value: "850",
               text: "850"
            }
         ],
         custentitycert_billing_uom: [
            {
               value: "3",
               text: "INVOICE GJ"
            }
         ]
      }
   }
]
since netsuite will stringify objects in logs
dont expect the logged properties to match the actual properties of your objects
lots of netsuite objects use .toJSON to generate printable objects that dont match the actual object
n
really, ok
had no idea
is there any way to getValue the "text" instead of "value"?
b
n
awesome thank you