Is it possible to add record producer variables to HR Document Templates

gowdash
Mega Guru

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 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@gowdash 

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);

AnkurBawiskar_1-1738223850990.png

 

${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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@gowdash 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader