erictgrubaugh
01/28/2019, 11:01 PM// data module for script
function findUserNotes(workId) {
log.audit({title: "[ATR:data] Searching associated User Notes..."});
// This structure is necessary due to the behaviour of TemplateRenderer.addCustomDataSource()
// failing to process a flat Array properly
return {
"notes": s.create({
type: "customrecord_ffp_work",
filters: [["internalid", s.Operator.ANYOF, workId]],
columns: [
"usernotes.author",
"usernotes.note",
"usernotes.notedate",
"usernotes.title"
]
}).run()
.getRange({start: 0, end: 1000})
.map(noteToObject)
}
}
// template usage
<#macro renderUserNotes>
<label>User Notes:</label>
<#list (usernotes!{}).notes![]>
<ul>
<#items as note>
<li>${note.notedate}: ${note.title} - ${note.note}</li>
</#items>
</ul>
<#else>
No associated User Notes.
</#list>
</#macro>
...
<p>
<@renderUserNotes />
</p>