Scripting in HR document templates

Justin Lucas
Kilo Sage

We have a requirement for populating a dynamic table in an HR document template so that it can be generated in PDF, printed, and signed by an employee. From the HR document template, we can reference fields on the case but we are not able to pull in a related list of data. For instance, we have a custom table that contains a one-to-many relationship between the case and related table, meaning an HR case can have many related records on this custom table. We are needing to populate a table in the HR document template using the records that are related to the case.

The only way I can think to make this happen is with scripting. Is it possible to call a script from an HR document template so that we can build the table in the script and print it on the template (similar to an email script in a notification)?

1 ACCEPTED SOLUTION

This is a great idea to be entered as a record in the Ideas section of the Community. This is a great way to facilitate others to vote on the idea and see results.

View solution in original post

6 REPLIES 6

Definitely, I created an idea and included some examples on how I think it should work. You can find the post here:

https://community.servicenow.com/community?id=view_idea&sysparm_idea_id=0adb0449dba78014feb1a851ca96...

I'll try to think of a workaround in the meantime.

Misael1
Tera Contributor

Hey, I had a requirement similar where dynamically I had to add complex information. I saw the document template script and it sounds familiar (such as email template). 

If you notice, the only thing that you send is just html so... an alternative is that you can use an auxiliary field where you are going to populate before an instert by a BR with all your code in HTML. 

At least it works for me. 

I did my test just using hr task template 

find_real_file.png

 

find_real_file.png

 

find_real_file.png

Regards!