Hi, does anyone know how to display the `value` ra...
# suitescript
a
Hi, does anyone know how to display the
value
rather than
text
of a field in a saved search result? For instance, my saved search is showing what you would see as a result from
getText()
ran on that field and instead I'd want it to show the result from
getValue()
s
Saved search doesn't really have this functionality for display purposes. You have more control using the analytics module.
You're best bet is to join to whatever record it is and pull the internalid from there (assuming its a list/record)
m
If what @Sandii suggested doesn't work for you, I think you can get there in some contexts by using a text formula along the lines of
{select_field_id.id}
but I don't know that I'd rely on it for anything business critical.
a
so specifically I am trying to get value of
addrphone
on
address
record so I'm using
{address.addrphone}
but it shows the text result of that field, and I am looking for the value result
m
I don't think I've ever used
getText()
on a phone-type field, how does it differ from
getValue()
? I usually just use
getText()
for select or multi-select fields.
s
Phone fields are just text fields with special length restrictions (can only be empty, or a string that is length 7 or more, up to the maximum 21 or 22 characters). They do not even have to contain a valid phone number, or even any numbers at all. getValue should return the actual text stored in the phone field. What are you looking for exactly? Do you see something in the UI that you are not getting in the search result?
a
the result shows the phone number with dashes, for example
<tel:5555555555|555-555-5555>
however, if you view the value from suitescript api such as running toJson on it or simply running getValue() on the field, it returns it without dashes
5555555555
, what I'm looking for is the result of getValue() without dashes in the saved search results
s
Can you REGEXP it maybe to remove the dashes?
s
What record type are you referencing this address field from? I wasn’t aware of any auto-formatting fields, but there may be something special about that one. Also, I would not assume that the results of toJson or JSON.stringify are going to match what you get from either getValue or getText. What you are getting is a raw representation of a JS object, and getValue or getText may have embedded logic that results in them returning something else. Regardless, this should remove all non-numeric characters from the result:
REGEXP_REPLACE({address.addrphone}, '[^[:digit:]]+', '')