``` const columnsObj = [ { ...
# suitescript
n
Copy code
const columnsObj = [
              {
                "name":"salesrep",
                "summary":"GROUP",
              },
                {
                    "name":"fxamount",
                    "summary":"GROUP",
                }
            ];
[...]

let thisValue = soResults[x].getValue(columnsObj[0]);
I have some code that along the way has the const above. I'm looping through search results and for each, looping through the columnsObj trying to pull back the result value. I've tried backticking / JSON.stringify'ing and a plethora of approaches but none give me a result value. If I take one of those columsObj objects and paste them directly in to the code at the point I assign the value to thisValue it works fine, kinda as expected really. Can someone advise on the syntax I should use to retrieve the result value using the array object, or failing that, a better way of approaching it please? Feeling mentally fried right now! (I've output columnsObj[0] and it is as expected too, there's no scope issue etc)
e
If you're building the search columns using the same array you could use
mySearch.columns[0]
otherwise
Copy code
const columnsObj = columns[0];
console.log(result.getValue(columnsObj));
n
The thing is I wanted to set my own object and not base it on the columns because the search could have more columns than I'm interested in. I'm biting the bullet and going to make use of the result.columns. Thanks for your help. Weirdly, just tried it and now I don't see values for getText but do for getValue for columns of type "select", freaky
say what now??? no type? I beg to differ...
b
that not how logging works
the logging module converts objects to json objects before printing
the log you are seeing is
Copy code
columnsObj[c].toJSON()
n
but if my columnsObj[c] logs as ... "type":"select" why can I not get the value of type in my code?
b
because
Copy code
columnsObj[c]
does not have a type property
n
Ok I need to think on this, I'm obviously tired as this isn't making sense that I output a JSON.stringified version of an object and see keys but cannot access them. Thank you for your help, I'll step off and think rather than test your patience further.
b
you would need to lookup what a toJSON method overrides
👍 1
n
OK thank you. I thought it'd be easy to dynamically decide if I need to getText or getValue based on the column type. Feel sure I've done this before. Thanks @battk
FYI I just looked in to toJSON and its overriding possibilities. Thanks I did not know that. 🧐