I know the `N/query` module doesn't have getText o...
# suitescript
a
I know the
N/query
module doesn't have getText or getValue like the search module does. That being said, how would one get the text, for a field? For example if I want text representation of the customer and not in the internal id? The solution I could think of is to join onto customer and then get name. But is there a more direct way to get it, or is that what I would need to do?
s
You can make the field value like
(fieldId#display}
to see the display instead.
a
@Sandii in the create column? I am getting an error when I try that. Are you sure that is the correct syntax?
s
Yep, I've used before. You can verify with the Analytics module in the UI.
For example...
Copy code
createColumn({
                formula: "NVL({custrecord_uom#display},'Base Unit')",
                type: query.ReturnType.STRING
            })
I believe you can also just set the
context
property instead
a
šŸ‘
@Sandii Worked. Thanks!
@Sandii What about changing the type? I see in your example above you usedĀ 
type: query.ReturnType.STRING
It seems that only works with formula. I tried adding a formula and just passed the field value straight to the formula, but that gets an error. I could map over the results and convert the types, but is there a more direct way? The reason I specifically want a string and not a number is because we also use the search module and that returns a string.
s
You would need to cast the value to a string in the formula to make the query give you a string back. That `type:`parameter just tells it what to expect/validate as the return value, it does not do anything to the return value.
TO_CHAR
is probably what you are looking for