Is it possible to add record producer variables to HR Document Templates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 11:45 PM
Dear Experts,
We are using HR PDF document template to generate employee joining forms like Provident Fund Nominees etc. We are collecting this info from a record producer, now the requirement is to generate a PDF Document which contains a few variables filled in by user. I see we are able to access the fields on the HR Case table in the HR Document template however, would like to know how to add variables?
We tried using ${variables.variable_name} in the HR document template, but it did not work.
Appreciate your valuable responses.
Best Regards,
Gowdash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 11:57 PM
Is it not working as per docs?
Add customized variables in a document template
if it doesn't work then it's a platform bug.
use template script and bring the variable data and use it
(function runTemplateScript(target /*GlideRecord for target task*/ , docTemplate /*GlideRecord for doc template*/ ) {
//Add your code here to return the dynamic content for template
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", target.sys_id);
gr.query();
if (gr.next()) {
return gr.variables.variableName;
}
})(target, docTemplate);
${template_script:fetch_variable_value} -> include in the body of template
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 06:48 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader