Document template - how to generate pdf with Subject Person in the file name

Community Alums
Not applicable

Hi everyone, 

After installing the Document Templates plugin, the file name of the generated pdf document no longer contains Subject Person name, but instead takes the name of the person who generated it.

Could you please share your solution if you have one?

Thank you in advance,

Victoria 

1 ACCEPTED SOLUTION

abirakundu23
Giga Sage

Hi @Community Alums ,

I faced similar issue. We can achieve this using customization.

Please create Before/insert BR in 'sys_attachment' table with global application scope.

 

(function executeRule(current, previous /*null when async*/ ) {
var case = new GlideRecord("sn_hr_core_case_global_mobility"); // put table name as per you configuration
case.addEncodedQuery('sys_id=' + current.table_sys_id);
case.query();
if (case.next()) {
var EmpName = case.subject_person.name;
}

current.file_name = 'Employee offer letter-' + EmpName;
// gs.info('EmpNameFilename' + current.file_name);
})(current, previous);

 

May be RCA record will be created post that please allowed RCA with target scope.

 

Please helpful & mark answer if it's really worthy for you.

View solution in original post

5 REPLIES 5

abirakundu23
Giga Sage

Hi @Community Alums ,

If it's solved your purpose, please accept my answer as well.