I have a custom list field that is using the nativ...
# advancedpdf
j
I have a custom list field that is using the native US States list. Whatever value they put in this list will display on the PDF. However, I am having trouble with Alabama. It won't show up. Every other state works. I looked at the internal ID list of US States in NetSuite and Alabam's internal ID is 0. I think this is what is messing things up. I tried a ?has_content and sure enough, Alabama returns as not having content because of the zero int id. I am trying to find some sort of expression in Freemarker that would get it. I can't just default to Alabama because the field may also be blank (which would cause different behavior in the PDF). Any insight or suggestions are welcome.
s
Not tested, but maybe try
?length == 0
length should be greater than 0 for any real number (even 0), but 0 for an empty string. not sure how nulls are handled, though
j
Thanks, I tried that. Null and Alabama both came back as a length of 0.
s
That is unfortunate. It’s ugly, but you could try to specifically detect the case where the value equals 0, and use Alabama for the name in that case, otherwise use the current behavior. Though, I am curious how or why 0 has a length of 0. Is
Is NetSuite even returning a 0 or is it removing the value somehow when it’s zero? You might want to try displaying the internal id to see what is happening.
j
The internal ID of Alabama is zero. The value of the field is always a state name, not an integer.
Well, always a state name or empty. But Freemarker is reading empty and Alabama as the same value.
s
Yes, I know. I meant, more specifically, that I’d expect the length of 0 to be, not zero. However, Netsuite has to pass the value to Freemarker, and it may be coming in as a string or a number, though in my experience they are almost always strings. And the string “0” should have a length of 1.
Freemarker can check if a value exists, with
??
, but depending upon how NetSuite sends null values, that might still be true. Oracle databases typically treat empty strings and Null as the same, and many applications built on an Oracle database rely upon that or take advantage of that fact.
d
I can't make it distinguish between no selection and Alabama. NetSuite is handing Freemarker an empty string for Alabama. I would log this as a defect Jessica
I tried
??
,
?length
,
?is_string
and
?string
. All resulted in the same output for no-selection and Alabama I suppose a workaround would be to use a custom list of states. I can't imagine maintaining such a list would be too much trouble 😄
j
I wonder if you could try squaring the number? Check if original == original ^ 2 Obv you would also need to manually code whatever internalID 1 is too
d
All of the values reaching Freemarker are strings, not the numerical id. So can't square them =\
☹️ 1