I have an invoice template that I have a custom fi...
# general
d
I have an invoice template that I have a custom field holding a JSON string of all charges to present in the PDF (I have done this multiple times before for other records) when I try and use #assign backingLines=record.custbody_ash_charge_details_for_invoic?eval!"\"[{chargeType: 1, chargeDate: 11/02/02}]\""/ I get the following error Failed to "?eval" string with this error: I have removed the default option and just left ?eval but still the same issue If I simply output the field directly it dumps the JSON string into the PDF fine. Any ideas? ---begin-message--- Syntax error in ?eval-ed string in line 1, column 8: Encountered "ipsum", but was expecting one of these patterns: If I run it on the invocie I get record.custbody_ash_charge_details_for_invoic?evalfreemarker.core.Environment@2042e45cFailed to "?eval" string with this error: ---begin-message--- The following has evaluated to null or missing: ==> null [
s
Your date is missing quotes chargeDate: 11/02/02 That'll cause a JSON eval error. It may be evaluating to 11 div 2 div 2 = 2.75, and if you have that displaying as a date, it's illegal
d
Sorry that was a bad example The actual data that it is evaluating is below (billdate is a string) [{"amount":800,"billdate":"02/02/2024","chargetype":-13,"use":"Actual","chargedate":"02/02/2024","id":2003,"invoice":34351,"invoiceline":"Technician - Offshore:5","invoiceln":2,"billingitem":12642,"memo":null,"projecttask":null,"quantity":1,"rate":800,"stage":"BILLED","subsidiary":15,"timerecord":334707,"memo_0":null}]
s
in my experience, JSON eval doesn't like null. I'd suggest making it an empty string ""
d
To cap this off - if I change ?eval to ?eval_json it works as expected