- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2020 03:05 PM
We have a requirement for an employment verification letter record producer, where when the attachment is created, it's name should include whoever opened the case, not who signed the document. Screenshot below, instead of the attachment displaying "Personal Travel- Leo Singh" it should display as "Personal Travel- Ali Sufiyan". Is there an OOTB way to accomplish this?
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2020 07:43 AM
Hi leo,
I have work around it and develop same scenario in my PDI, I success to achieve it.
1. I created Business rule in Sys_attachment table. It will run always.
2. Then write a following code in Advanced tab.
Note change the Sys_id of Hr_Service as per your HR_Service and also update table name as per your required table.
//Get Case information to make sure that update only for your HR Case.
var getCase = new GlideRecord('sn_hr_core_case_workforce_admin');
getCase.get(current.table_sys_id);
getCase.query();
if((getCase.hr_service == 'c741adf51b8a8890db9afd115b4bcb11') && (current.table_name == 'sn_hr_core_case_workforce_admin')){
//Once we make sure the attachment is in our case, we will update the attachment
var fileName = getCase.pdf_template.name +"-" + getCase.opened_for.getDisplayValue();
current.file_name = fileName;
current.update();
}
Please mark as correct if it resolve your issue or let me know if further explanation needed.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2020 03:17 PM
Hi,
I don't personally have the HR application/plugin in my instances, but I would assume someone (a developer or implementer, etc.) created a business rule for the sys_attachment table to rename the file, automatically, and add in the opened_by name. Perhaps whoever did this misread the requirements and did opened_by instead of opened_for.
I would recommend reviewing your business rules (BR), looking specifically at the sys_attachment table rules and seeing if you can spot the BR doing this (it would be most likely associated to a condition where it talks about the "table name" being the HR table or an HR related table. Then go to the advanced tab (about scripting) and see if you can point out where they may be using the wrong field as the suffix for the filename.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2020 05:01 PM
Hi,
You can achieve this using AFTER business rule. Check below link.
https://community.servicenow.com/community?id=community_question&sys_id=115d85aadb9c2b848e7c2926ca9619f5
Please mark reply as Helpful/Correct, if applicable.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2020 07:43 AM
Hi leo,
I have work around it and develop same scenario in my PDI, I success to achieve it.
1. I created Business rule in Sys_attachment table. It will run always.
2. Then write a following code in Advanced tab.
Note change the Sys_id of Hr_Service as per your HR_Service and also update table name as per your required table.
//Get Case information to make sure that update only for your HR Case.
var getCase = new GlideRecord('sn_hr_core_case_workforce_admin');
getCase.get(current.table_sys_id);
getCase.query();
if((getCase.hr_service == 'c741adf51b8a8890db9afd115b4bcb11') && (current.table_name == 'sn_hr_core_case_workforce_admin')){
//Once we make sure the attachment is in our case, we will update the attachment
var fileName = getCase.pdf_template.name +"-" + getCase.opened_for.getDisplayValue();
current.file_name = fileName;
current.update();
}
Please mark as correct if it resolve your issue or let me know if further explanation needed.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2021 01:28 AM
Hi Sufiyan,
Am having similar requirement where any attachment from sn_hr_core_case_relations table is moving to 'sn_hr_ef_employee_document' table i need to rename as Field1_field2_field3(these fields from sn_hr_ef_employee_document table)
And also when its directly creating in sn_hr_ef_employee_document also same requirement.
Any help on this?