Problem with PDF file name for PDF Document Template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 08:55 AM - edited 10-13-2024 09:08 AM
Hi
I'm having an issue with the file name generated from the PDF Document Template. The file name is supposed to follow a format that includes the template name and the logged-in user's name (the display name of the user signing the document). I expect that once the PDF is signed by a specific user, their name will be appended to the file name. However, instead of using the signing user's name, the file name is showing the name of the person who provided approval for HR Case.
It seems that this name is being pulled from the approval step in the HR Service Service Activity step, where a manager is required to provide approval for the HR Case. Once approval is given, the name of the manager who clicked 'Approve' is being added to the file name.
Here’s the workflow:
1. HR Service includes a Service Activity approval step ('Approvers from case' field is populated with Subject person Manager)
2. Once the form is submitted, an HR Case is created with an approval task.
3. Subject person’s manager provides approval.
4. After approval, a Document task is generated for the subject person. Subject person needs to sign the PDF document.
5. Once PDF is submitted, it is added to the HR Case, but the PDF title incorrectly follows the format: <PDF Template name> + <manager's name>, instead of the signing user's name (subject person).
This is defined in the createPdfForDocument() in SI: hr_PdfUtils
Is this expected behavior or a bug? How can I solve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 10:59 AM
Hello @miro2 ,
It looks like the issue with the PDF file name is related to how the name is being constructed in the createPdfForDocument() function. Currently, it's appending the manager's name instead of the signing user's name.
To resolve this, you need to ensure that the user who is signing the document (the subject person) is being referenced correctly in your code. Here's a suggestion:
-
Instead of using gs.getUserID() to get the currently logged-in user, you might want to obtain the user ID of the subject person from the HR Case or the Document task.
-
Modify the create PdfForDocument() function to retrieve the display name of the subject person when constructing the PDF name. This can be done by fetching the appropriate user record based on the subject person's details.
For example, replace this part:
if (user.get(gs.getUserID()))
pdfName = pdfName + "-" + user.getDisplayValue();
With logic that gets the subject person’s user ID and retrieves their display name instead.
Let me know if you need further assistance or clarification!
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 01:33 PM
Hi @Aniket Chavan
I'd prefer to avoid any customization in OOB script include.
I'm also trying to understand the behavior behind this. Why is the manager's name of the subject person being populated in the PDF file name instead of the name of the user who actually signs the document?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 10:02 AM
This is an oddity to me, as well. It seems like we'd always want the name of the subject person or opened for person and not the name of the user who triggered the file to be created. Perhaps the only reason to capture the name of the person who triggered the file to be created is if there is no Subject Person or Opened For user. If nothing else, it seems like this should be a part of the configuration of the document and not something hard-coded into a script.