In the FreeMarker source code of Advanced PDF/HTML...
# ask-stanley-ai
a
In the FreeMarker source code of Advanced PDF/HTML templates, how do I reference the internal ID of the transaction record to be rendered? I'm trying to display extra information but only on the Sales Order I'm troubleshooting the PDF rendering for. The ${record} object is already available, I just have to get the internal ID from it, and trying to use <#if record.id == 12345 > results in an error:
Copy code
Can't compare values of these types. Allowed comparisons are between two numbers, two strings, two dates, or two booleans.
Left hand operand is a hash+string (wrapper: com.netledger.templates.model.StringModel).
Right hand operand is a number (wrapper: f.t.SimpleNumber).
The blamed expression:
==> record.internalid == 12345  [in template "template" at line 203, column 22]
c
AI generated answer (using internal Slack threads):
In the FreeMarker source code of Advanced PDF/HTML templates, you can reference the internal ID of the transaction record to be rendered using
${record.internalid}
. However, the error you're encountering is due to the fact that you're trying to compare a string (the internal ID) with a number. In FreeMarker, you can't directly compare a string with a number. You need to convert the string to a number first. You can do this using the
?number
built-in function in FreeMarker. Here's how you can do it:
Copy code
<#if record.internalid?number == 12345>
This will convert the internal ID to a number before comparing it with 12345. Please note that this will only work if the internal ID is a numeric string. If it contains any non-numeric characters, you'll get an error. In that case, you might need to use a different approach, such as comparing the internal ID with a string:
Copy code
<#if record.internalid == "12345">
This will compare the internal ID with the string "12345", which should work regardless of whether the internal ID is a numeric string or not. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826732
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825768769
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825088859
Please provide your feedback on this answer.