HR document template

Vadla Srimaan
Tera Contributor

Hi,

We are generating HR document templates using BR when a record producer is submitted.

PDF are attaching to the case, but the variables/ fields configured on the templated are not displaying on the generated PDF.

 

${subject_person.company}

${subject_person.location}

 DOB: ${variables.date_of_birth_dach}

 

 

First two are HR case fields and DOB is a record producer variable. None of them are displayed

How can we fix this?

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Vadla Srimaan 

although ServiceNow says syntax is ${variables.variableName}, but it's sad that it doesn't work

1 other member also tried the same and it didn't work, I provided solution for that

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

You can use document template script for that

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("your table name");
    gr.addQuery("sys_id", target.sys_id);
    gr.query();
    if (gr.next()) {
        return gr.variables.variableName;
    }

})(target, docTemplate);

AnkurBawiskar_0-1747230739153.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

View solution in original post

6 REPLIES 6

Thanks Ankur.

 

@Vadla Srimaan 

Glad to help.

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