If I have a field of type Document in a Transactio...
# general
j
If I have a field of type Document in a Transaction, how do I 
<#include>
 that document in a template?  The document is XML.  My field is called 
custbody_adf
. If I simply print out the value of the field in the template, it shows up as a hyperlink in the PDF (underlined, clickable), so I have confirmed that the template, in theory, knows the URL of that file. e.g. 
<p>custbody_adf is ${custbody_adf}</p>
When I tried 
<#include "${record.custbody_adf}"/>
 though, I get an error when I try to print using the template. The only solution seems to be to have a separate field (
custbody_adf_url
) that stores the URL of the file, and even then I have to split it up because the
<#include>
doesn’t work when you are including a variable that has ampersands in it.... Right now I have this, which is overly cumbersome and also I really don’t want to have to have a separate field just to be able to get the URL of the file.
Copy code
<!-- Split the adf_url in the main URL and the arguments -->
<#assign adf_url_first_split = record.custbody_adf_url?split("?")/>

<!-- The arguments -->
<#assign adf_url_arguments = adf_url_first_split[1]/>

<!-- Split the arguments on their ampersands -->
<#assign adf_url_argument_split = adf_url_arguments?split("&")/>

<!-- The arguments -->
<#assign adf_url_id_argument = adf_url_argument_split[0]/>
<#assign adf_url_c_argument = adf_url_argument_split[1]/>
<#assign adf_url_h_argument = adf_url_argument_split[2]/>
<#assign adf_url_xt_argument = adf_url_argument_split[3]/>

<!-- Split each argument on the equals sign. -->
<#assign adf_url_id_split = adf_url_id_argument?split("=")/>
<#assign adf_url_c_split = adf_url_c_argument?split("=")/>
<#assign adf_url_h_split = adf_url_h_argument?split("=")/>
<#assign adf_url_xt_split = adf_url_xt_argument?split("=")/>

<!-- The value for the arguments -->
<#assign adf_url_id_value = adf_url_id_split[1]/>
<#assign adf_url_c_value = adf_url_c_split[1]/>
<#assign adf_url_h_value = adf_url_h_split[1]/>
<#assign adf_url_xt_value = adf_url_xt_split[1]/>

<#include "<https://XXXXXX.app.netsuite.com/core/media/media.nl?id=${adf_url_id_value}&c=${adf_url_c_value}&h=${adf_url_h_value}&_xt=${adf_url_xt_value}>"/>
c
Are you trying to get the contents of the file into the pdf or just the url
You should be able to do something like SA: 82703
j
The contents
nothing needs to be a link, I just need to be able to
<#include>
the content of the file
which I can do if I
<#include>
the explicit path to the file, but I need to get that dynamically from the field on the transaction (as the file is different for each tx)
c
Thats interesting. I've never pulled in the contents like that. I'm wondering if it needs a tag like images or the ?url. There's a tag in there for urls that you append the end of the string so it works correctly as a URL.
j
Yeah, I did experiment with that some and got nowhere