FreeMarker templates: If I have this list (screens...
# suitescript
c
FreeMarker templates: If I have this list (screenshot below), and I declare <#list record.apply as apply> Should I then be able to declare apply.tranid and get the value of the tranid field on the Bill record? This if statement <#if apply.tranid?starts_with("PO28")> is failing because it can't see apply.tranid (coming back as empty/blank). It appears there are multiple fields that cannot be pulled out from apply (record.apply) and I can't work out why.
w
Have you tried printing out the different keys? is tranid really available? #C466X49JB https://freemarker.apache.org/docs/ref_builtins_hash.html#ref_builtin_keys
c
I've always delegated freemarker until today, I'm just learning it.
so does record.apply give me access to all fields on the related record?
w
Wouldn't bet on it
c
Yeah, looks like it doesn't. How do I know what it does and does not give access to?
Is there any general rule or guidance?
w
According to the wysiwyg editor:
🙌 1
Sooo. refnum perhaps?
c
Bit of a pain
thanks though
w
Hey, this is #C29HQS63G Slap on a beforeLoad that runs on PRINT and add whatever you want 🙂
💯 1
c
If there was a field not in the above list, is there a way to get that field?
Yes.. I could use a script 😄
I'm a hammer and everything is a nail afterall!
😂 2
n
Dealing with this same type of issue with email templates. Gave up and wrote a ue script that just pastes all the fields i need in a text area on the record, then use a ?eval_json on that field.
c
How are you pushing the fields back to the template?
w
add a custom field to the form on beforeLoad and set a defaultValue on it with whatever you need. Usually a JSON.stringiify(Object). Then run eval_json as Nathan wrote. custpage_your_field?eval_json.
this 1
n
Copy code
// get the custom field value with the strigified json object
<#assign emailObj = transaction.customFieldName?eval_json />

// reference the fields in the emailObj
${emailObj.subsidiaryName}
c
haha
w
😎