|
| 1 | +# Attachment Downloads Logger |
| 2 | + |
| 3 | +A ServiceNow utility that logs attachment download activities by adding comments to the work notes of the associated record, enhancing visibility and ensuring compliance. |
| 4 | + |
| 5 | +## Challenge |
| 6 | + |
| 7 | +Tracking attachment downloads in ServiceNow can be critical for maintaining data security and compliance. Without proper logging, it becomes difficult to identify who accessed sensitive information and when. This utility addresses this challenge by providing an automated solution to log attachment download activities directly in the work notes of the record. |
| 8 | + |
| 9 | +This tool is particularly useful in scenarios where data access needs to be monitored for compliance purposes or to ensure accountability in data handling. |
| 10 | + |
| 11 | +## Description |
| 12 | + |
| 13 | +The Attachments Download Logger Script Action is designed to automatically add work note of a record whenever an attachment is downloaded. This ensures that all attachment access activities are logged, providing a clear audit trail for administrators and compliance officers. |
| 14 | + |
| 15 | +## Functionality |
| 16 | + |
| 17 | +The Attachments Download Logger Script Action provides the following capabilities: |
| 18 | +- Automatically logs attachment download activities in the work notes of the associated record. |
| 19 | +- Captures details such as the user who downloaded the attachment and the timestamp and what attachment was downloaded. |
| 20 | +- Enhances visibility into data access activities for better compliance and accountability. |
| 21 | +- Operates seamlessly in the background without requiring manual intervention. |
| 22 | + |
| 23 | +## Usage Instructions |
| 24 | + |
| 25 | + |
| 26 | +### Creating the Script Action |
| 27 | + |
| 28 | +To create the Script Action for the Attachment Download Logger, follow these steps: |
| 29 | + |
| 30 | +1. Navigate to **System Policy > Events > Script Actions** in your ServiceNow instance. |
| 31 | +2. Click on the **New** button to create a new Script Action. |
| 32 | +3. Fill in the following fields: |
| 33 | + |
| 34 | + - **Name**: `Add worknote for attachment download` |
| 35 | + - **Event Name**: `attachment.read` |
| 36 | + - **Active**: `true` |
| 37 | + - **Order**: `100` (or any appropriate order value based on your instance configuration) |
| 38 | + - **Script**: |
| 39 | + ```javascript |
| 40 | + //Add the attached script action code |
| 41 | + |
| 42 | + ``` |
| 43 | + |
| 44 | +4. Click **Submit** to save the Script Action. |
| 45 | + |
| 46 | +This Script Action will now automatically log attachment download activities in the work notes of the associated record. |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +### Customizations |
| 51 | + |
| 52 | +You can customize the script to include additional details, such as the IP address of the user or the reason for the download. Additionally, you can restrict the logging functionality to specific tables or user roles based on your requirements. |
| 53 | + |
| 54 | +If you want to restrict the logging functionality to a specific table, you can use the `current.table_name` property in your script. For example, to apply the logging only to the `incident` table, you can add the condition in the **condition Script** field as below. |
| 55 | + |
| 56 | +```javascript |
| 57 | +current.table_name == 'incident' |
| 58 | +``` |
| 59 | + |
| 60 | +This ensures that the logging functionality is executed only for records in the `incident` table. |
| 61 | + |
| 62 | + |
| 63 | +## Category |
| 64 | + |
| 65 | +Server-Side Components / Script Actions / Attachment Downloads Logger |
| 66 | + |
| 67 | +## Screenshots |
| 68 | +<img width="1256" height="132" alt="2025-10-23_22-57-59" src="https://github.com/user-attachments/assets/dbd95461-2b81-40d8-9425-f3c98e724dd1" /> |
0 commit comments