i'm trying to use ?eval on a long text field which...
# advancedpdf
a
i'm trying to use ?eval on a long text field which contains a JSON object. however, i can't seem to save the PDF without an error - i have an <#if has_content> check in front of my use of eval, but it still says the line with ?eval is evaluating to null, i assume because as part of the validation (just like in the PDF preview) it populates some test value into that long text field, so it passes the has_content check but then fails the eval. or at least, that's my best guess. has anyone run into this/have any ideas how to move past it?
question not answered 1
d
care to share the offending code?
a
Copy code
<#if record.custbody_singapore_gst?has_content>
<#assign singaporeGSTData = record.custbody_singapore_gst?eval />
  For GST Reporting Purposes<br />
...
<br />
</#if>
the 2nd line assigning the variable is what errors out 😕 the field in question will either be blank or contain a JSON-formatted string.
d
yeah, I think your theory of it being a part of the validation is correct, as I'm getting this error mesage:
---begin-message---
Syntax error in ?eval-ed string in line 1, column 8:
Encountered "*ipsum*", but was expecting one of:
".."
"..*"
")"
---end-message---
ipsum
giving away that they're feeding the fields with Lorem ipsum to see if they error. I would say submit anyway and test by printing actual transactions, both with and without that field populated.
also please, please read the warning message on the freemarker docs for ?eval If we were on the latest version of freemarker, you should instead be using ?eval_json
👍 1
j
Copy code
<#if record.item?has_content>
  <#if record.customfield?has_content>
    <#assign data = record.customfield>
    <#assign m = data?eval>
    <#list m["origItems"] as itemList>
this is the chain of checks that we had on our netsuite-provided pdf template (we had a json field at the header level which replicated the item list). It worked, but you had to "save anyway" past the error
d
you had to "save anyway" past the error
Good to know I arrived at the official NetSuite workaround 🤣🙃
a
thanks for confirming all - definitely a bummer because it makes it harder to identify any actual errors outside of that one if you are indefinitely having to "save anyway", plus not being able to use the PDF preview button.