Employee Document Management - Automatically moving attachment in HR service to EDM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 07:05 AM
I'm creating an HR service where the requestor will specify the document type, employee name/ID and then upload the attachment. That attachment should be moved to the specified employee's documents and be put in the document type that is specified by the requestor. My question is when I go to HR Service Configuration and check the "Automatically Move Attachments" box, it requires a document type. My document type is going to change though depending on what the requestor selects. What do I select for this required field then?
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:28 PM - edited ‎01-19-2024 07:29 PM
Here is the Business rule for further analysis - "Move attachments to employee files"
The 'Automatically move attachments' checkbox will automatically move attachments to the document type selected on the HR service form.
For users to be able to view document types on the portal (assuming you are going to create a reference to that table), they will need to pass the security policies on that document type.
If you are not going to create a reference but instead provide a simple dropdown, then customization will be needed to change the type of the document once it's added to the document table.
For moving documents to a particular type selected by the user, additional customizations will be required.
If you want to auto move the attachments, then you will need to update their type after they have been added to the document table.
Please accept solution OR mark helpful.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 06:17 AM
Do you know what the customizations would be if I want the document to move to the correct document type that is selected by the requestor from a dropdown menu?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 08:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 07:25 AM
@tworzala wrote:I'm creating an HR service where the requestor will specify the document type, employee name/ID and then upload the attachment. That attachment should be moved to the specified employee's documents and be put in the document type that is specified by the requestor. My question is when I go to HR Service Configuration and check the "Automatically Move Attachments" box, it requires a document type. My document type is going to change though depending on what the requestor selects. What do I select for this required field then?
Here's how you can address the requirement for a document type while allowing for dynamic selection based on the requestor's input:
1. Bypass the Field in HR Service Configuration:
- Uncheck the "Automatically Move Attachments" box in HR Service Configuration.
- Create a Business Rule: This rule will trigger upon attachment upload and handle the dynamic document type selection and movement.
2. Business Rule Details:
- Condition: Check for attachment upload in the HR service.
- Action:
- Retrieve the document type selected by the requestor.
- Use the GlideRecord API to move the attachment to the correct employee's documents under the specified document type.
3. Code Example (GlideRecord):
var gr = new GlideRecord('sys_attachment'); gr.addQuery('table_sys_id', current.sys_id); // Assuming 'current' refers to the HR service record gr.query(); while (gr.next()) { var docType = gr.employee_document_type; // Retrieve the document type from the request var employeeGR = new GlideRecord('sys_employee'); employeeGR.get(current.employee); // Assuming 'current.employee' holds the employee ID gr.employee = employeeGR; gr.employee_document_type = docType; gr.update(); }
4. Additional Considerations:
- Validation: Ensure the requestor selects a valid document type from a predefined list or table.
- Error Handling: Implement error handling to gracefully handle potential issues like invalid document types or employee records.
- Testing: Thoroughly test the business rule to guarantee correct attachment movement in various scenarios.
5. Alternative Approach: Script Include:
- If you prefer not to use a Business Rule, consider creating a Script Include with similar logic and calling it from a custom button or UI action.
By following these steps and tailoring them to your specific ServiceNow setup, you'll achieve the desired functionality of dynamically moving attachments to the correct document types based on the requestor's input within your HR service.