PROLIN support
  • news
  • downloads
    • Smart Client 14
    • Smart Client 2020
    • Power Server 12 LTS
    • Power Server 14
    • Power Server 2020

Orphaned Attachment Cleanup tool

Website under construction

  • product documentation
    • Smart Client
      • Smart Client 14
        • PROLIN Smart Client Installation Guide
          • Installation
          • Using the Smart Client
        • PROLIN Smart Client User Manual
          • Introduction
            • User Interface
            • Quality
            • Accessibility
          • Usage
            • Starting
            • Application Menu
            • Changing User Options
            • Closing the Client
            • When the Client Does Not Start
            • Updating the Client
            • Changing Supported Service Packs
            • Using the Client Behind a Firewall
            • Support
            • Help Improve the Client
          • Navigation
            • Parts of the Console
            • Customizing the Console
            • Using Action Windows
            • Parts of a View
            • Navigating Trees
            • Parts of a Form
            • Shortcut Keys
          • Views
            • Finding Information
            • Finding and Opening a View
            • Changing View Options
            • Creating Personal Views
            • Opening and Switching Multiple Views
            • Exporting View Data
            • Table Views
            • Explorer Views
            • Chart Views
            • Scheduler Views
            • Dashboard Views
            • Gauge Views
          • Forms
            • Set the Default Form
            • Navigating Items in a Form
            • Understanding the Information in a Form
            • Required Fields
            • Starting Form Actions
            • Managing Attachments in a Form
            • Entering Information
            • Creating and Changing Relations
            • Copying Item Information
            • Text Snippets
          • Reporting
            • Running Reports by End Users
            • Report Designer
              • Starting the Report Designer
              • Example Reports
              • Run Reports from the Designer
              • Save Reports
            • Report Editing Basics
              • Basic Operations
                • Controls Positioning
                • Change Measurement Units of a Report
                • Change Page Settings of a Report
              • Report Types
                • Table Report
                • Master-Detail Report
                • Multi-Column Report
              • Navigation
                • Add Bookmarks
                • Create Hyperlinks
                • Add a Cross-Reference
              • Styles and Conditional Formatting
                • Understanding Style Concepts
                • Use Odd and Even Styles
                • Conditionally Change a Label’s Text
              • Change the Layout of Report Elements
              • Change Fonts and Colors of Report Elements
              • Delete Report Elements
              • Add or Modify Static Information in Your Report
              • Use Mail Merge in Report Elements
              • Add Calculated Fields to a Report
              • Add Parameters to a Report
              • Change Value Formatting of Report Elements
              • Change or Apply Data Filtering to a Report
              • Change or Apply Data Grouping to a Report
              • Add Totals to a Report
              • Add Page Numbers and System Information to a Report
            • Advanced Report Topics
              • Use Parameters in Filters
              • Charts
                • Create Chart
              • Sub Reports
                • Pass Parameters to Sub Report
            • Importing/Exporting Reports
            • Starting Reports from a Form or View
            • Changing the Print Layout
          • Daily Tasks
            • Working with My Tasks
            • Working with Service Today
            • Using Advanced Find
            • Editing Filters
            • Using Shortcut Keys
          • Items
            • Creating an Item
            • Creating Multiple Configuration Items at Once
            • Updating Multiple Items at Once
            • Deleting an Item
            • Sending E-Mail Messages from Items
          • Advanced
            • Command Line Automation
            • Variable Expansion
            • View Performance Setting
            • Delay Refresh after Save
            • Service Call Hierarchy
          • Administration
            • Starting the Administration Module
            • Navigation
            • Mapping Service Desk functions
      • Smart Client 2020
    • Power Server
      • Power Server 12.2 LTS
        • PROLIN Power Server LTS Installation Guide
          • Installation
            • System Requirements
            • Preparing Installation
            • Installing PROLIN Power Server
            • Uninstalling PROLIN Power Server
        • PROLIN Power Server LTS Operations Manual
          • Introduction
          • Getting Started
            • Migration Guide
            • Database Migration
          • Using Power Server
            • Communication
            • Storage
            • Advanced Topics
              • Alternate Startup Mode
              • Backwards Compatibility
            • Client Access Licenses
              • Setup Power Server
              • Create CALs
            • Command Line Interface
              • Status
              • Install
              • Uninstall
              • Run
              • Start
              • Stop
            • Diagnostics
              • Logging
              • Instrumentation
            • Single Sign-On (SSO)
              • Setup Power Server
              • Create Account
              • Setup Smart Client
              • Troubleshooting
          • Server Management Console
            • Overview
            • Server Configuration
              • Communication Settings
              • Security Settings
              • Storage Settings
              • Services Settings
              • Advanced Settings
            • Server Monitoring
              • Monitoring the Local Host
              • Monitoring Remote Hosts
          • Services
            • Global Search
            • REST API
            • SMTP
          • Tools
            • Legacy Tools
          • Appendix
            • Supported Attachments
        • PROLIN Power Server LTS REST-based Web API
          • Open Data Protocol
          • Current Implementation
          • REST API Fundamentals
            • Programming Using the REST API
            • Primitive Data Types
            • OData Queries
            • Ordering
            • Paging
            • Projection
            • Navigation
            • Filtering
            • Creating a New Resource
            • Updating an Existing Resource
            • Deleting a Resource
            • Relating Resources
            • Invoking Actions or Functions
            • Me Endpoint
          • Security
            • Token-Based Authentication
            • Transport Layer Security (TLS)
            • IP Address Restrictions
          • Advanced Scenarios
            • Working With Attachments
            • Custom Fields
            • Using PING
            • Open API Explorer
            • OData Annotations
            • Prefer Header
      • Power Server 14
        • PROLIN Power Server Installation Guide
          • Installation
            • System Requirements
            • Preparing Installation
            • Installing PROLIN Power Server
            • Uninstalling PROLIN Power Server
        • PROLIN Power Server Operations Manual
          • Introduction
          • Getting Started
            • Migration Guide
            • Database Migration
          • Using Power Server
            • Communication
            • Storage
            • Advanced Topics
              • Alternate Startup Mode
              • Backwards Compatibility
            • Client Access Licenses
              • Setup Power Server
              • Create CALs
            • Command Line Interface
              • Status
              • Install
              • Uninstall
              • Run
              • Start
              • Stop
            • Diagnostics
              • Logging
              • Instrumentation
            • Single Sign-On (SSO)
              • Setup Power Server
              • Create Account
              • Setup Smart Client
              • Troubleshooting
          • Server Management Console
            • Overview
            • Server Configuration
              • Communication Settings
              • Security Settings
              • Storage Settings
              • Services Settings
              • Advanced Settings
            • Server Monitoring
              • Monitoring the Local Host
              • Monitoring Remote Hosts
          • Services
            • Global Search
            • REST API
            • SMTP
          • Tools
            • Legacy Tools
          • Appendix
            • Supported Attachments
        • PROLIN Power Server REST-based Web API
          • Open Data Protocol
          • Current Implementation
          • REST API Fundamentals
            • Programming Using the REST API
            • Primitive Data Types
            • OData Queries
            • Ordering
            • Paging
            • Projection
            • Navigation
            • Filtering
            • Creating a New Resource
            • Updating an Existing Resource
            • Deleting a Resource
            • Relating Resources
            • Invoking Actions or Functions
            • Me Endpoint
          • Security
            • Token-Based Authentication
            • Transport Layer Security (TLS)
            • IP Address Restrictions
          • Advanced Scenarios
            • Working With Attachments
            • Custom Fields
            • Using PING
            • Open API Explorer
            • OData Annotations
            • Prefer Header
  • projects
    • Smart Suite RESTAPI
      • Securing the Smart Suite RESTAPI
    • Smart Integration Server (python)
      • version 2024.10.6
  • how-to

On this page

  • Introduction
  • Prerequisites
    • Database access
    • ODBC
  • Installation
    • Setup steps
    • Manage Configuration
    • Test Database Connection
  • Running the Orphaned Attachment Cleanup tool
  • Orphaned Attachments Cleanup

Orphaned Attachment Cleanup tool

OACtool

version: 2024.10.6
date: February 2025

Introduction

The Orphaned Attachment Cleanup tool was created after it was discovered that attachments would not always get deleted from the attachment server when deleting the application item it was attached to.
Its initial purpose was to find files on the attachment server without an entry in the REP_ATTACHMENTS table and when instructed remove those orphaned files.
Added-on was a function to list Attachments (entries in REP_ATTACHMENT) without the physical file on the attachment server.
It now also detects empty files on the Attachment server, as well as Attachments that are missing a value in the Entity reference column, which results in an error when trying to open or save the attachment in Smart Client and the legacy client.
The program scans the Attachments table and the Attachment server and creates a local database.
At the end of the run it creates a text based report with the results.
The idea is to run the program twice. Once to create the database and the report. After verification the program can be run a second time to remove the orphaned attachments.

Prerequisites

Database access

The oactool needs to be able to connect to the application database with read privileges. It also needs to be able to connect to the Attachment server. The Attachment server details are retrieved from the application database.

ODBC

The program needs an ODBC data source definition to connect to the application database.
The data source definition needs to use a 64-bit ODBC driver, because the oactool.exe is a 64-bit executable.
The ODBC driver installation and ODBC data source configuration are described separately in the ODBC configuration how-to article.

Installation

The oactool is distributed as a ZIP file.
The default location to unzip into is the C:\Program Files\PROLIN\Integration Server folder.
The result would look like this.

C:\Program Files\PROLIN\Integration Server
  |____oactool\
  |       |____lib\
  |       |      |____*
  |       |____wsw\
  |       |      |____oactool-service.exe
  |       |      |____oactool-service.exe.config
  |       |      |____oactool-service.xml
  |       |____oactool.exe
  |       |____oactool.py.config.dist
  |       |____frozen_application_license.txt
  |       |____python3.dll
  |       |____python312.dll 

Setup steps

You might need Administrator privileges to extract the software to the program files folder, set permissions on and edit configuration files.

If you have not already done so, please extract the files in the ZIP folder to your preferred destination.
Then open an elevated command line and navigate to said destination.

cd C:\Program Files\PROLIN\Integration Server\oactool

Run the program to verify the version.

oactool --version
PROLIN Smart Integration Server - oactool
(build - 2024.10.5)
(C)2019+ PROLIN

To see usage and options, use the --help parameter.

oactool --help
usage: oactool [-h] [--create-directories] [--version] [--configfile CONFIGFILE] [--logfile LOGFILE]
               [--loglevel LOGLEVEL] [--logstyle LOGSTYLE] [--print-named-configs] [--print-configdb-content]
               [--manage-config] [--named-config NAMED_CONFIG] [--test-connection] [--remove-orphans]
               [--keep-database]

PROLIN Smart Integration Server - oactool

options:
  -h, --help            show this help message and exit
  --create-directories  create directories if needed
  --version             print version info and exit
  --configfile CONFIGFILE
                        use (alternate) configuration file
  --logfile LOGFILE     set log file name
  --loglevel LOGLEVEL   set loglevel [DEBUG, INFO, WARNING, ERROR, CRITICAL]
  --logstyle LOGSTYLE   set logstyle [FILE, STREAM, TIMEROTATING, SIZEROTATING]
  --print-named-configs
                        print named configs (stored in local config database)
  --print-configdb-content
                        print content of local config database
  --manage-config       create/update named config and store in local database
  --named-config NAMED_CONFIG
                        use named config (stored in local database)
  --test-connection     test connection to SmartSuite database
  --remove-orphans      remove orphaned files from attachment server
  --keep-database       keep database instead of creating a new database and gather file and attachment information.

The program expects, but not requires, a configuration file, i.e. oactool.py.config, in the same directory as the exe file. The distribution contains configuration files with an additional .dist suffix that can be used to create a configuration file. If you want to change the program’s defaults you can also use command line parameters and/or environment variables. Environment variables take precedence over default values and configuration settings in a configuration file. Command line parameters in turn take precedence over environment variables.

Note
When the software has been upgraded, the distributed configuration files might have changed. Please compare with the active configuration file(s) to see if any changes are required.

When you run the program for the first time, or without a configuration file, it will likely complain…

oactool
config file "C:\Program Files\PROLIN\Integration Server\oactool\oactool.py.config" does not exist
expected directory "F:\temp\SISpy\adm\oactool\config" does not exist
expected directory "F:\temp\SISpy\work\oactool" does not exist
An error occurred.
Expected directories do not exist, please check settings

usage: oactool [-h] [--create-directories] [--version] [--configfile CONFIGFILE] [--logfile LOGFILE]
               [--loglevel LOGLEVEL] [--logstyle LOGSTYLE] [--print-named-configs] [--print-configdb-content]
               [--manage-config] [--named-config NAMED_CONFIG] [--test-connection] [--remove-orphans]
               [--keep-database]

You will notice that the program requires a specific set of folders, hence the error messages.
It is highly unlikely that these folders exist in the default location when this is a greenfield installation. You will need to verify that the folders - all starting with drive F: - are acceptable.
If not, adjust the setting for these folders in the configuration file, and uncomment the line by removing the # at the beginning.
It is recommended to select a location outside the Program Files folder.

You then need to run the program again.
This time with the --create-directories parameter to instruct the program to create the folders it needs.
Once the folders are created successfully the server will prompt for additional values for the default config.
These settings are stored in a configuration database and any account credentials are stored encrypted.

oactool --create-directories
created C:\temp\SISpy\adm\oactool\config
schema has no programs table - programs
schema has no programs table - programs
Configuration Steps - section: Smart Suite Database
Database ('mssql', 'oracle11g', 'oracle12c', 'oracle18c', 'oracle19c') [mssql]:
Database ODBC DSN [servicedesk]: smartsuite
Use Windows Authentication  ('Yes', 'yes', 'No', 'no') [No]:
Database Username (read access) [sdread]: servicedesk
Database Password: 
Repeat please: 
Configuration "default" saved. Please restart

Note
For Database ODBC DSN use the name of the data source created earlier.

Note
When entering or confirming the password, the input is not shown.

Manage Configuration

If you need to change the configuration settings, you need to re-run the program configuration. Assuming the default configuration, use the --manage-config parameter and complete the dialog.

oactool --manage-config
Configuration Steps - section: Smart Suite Database
Database ('mssql', 'oracle11g', 'oracle12c', 'oracle18c', 'oracle19c') [mssql]:
Database ODBC DSN [servicedesk]: smartsuite
Use Windows Authentication  ('Yes', 'yes', 'No', 'no') [No]:
Database Username (read access) [sdread]: servicedesk
Database Password: 
Repeat please: 
Configuration "default" saved. Please restart

Test Database Connection

If you want to test the connection to the database, use the --test-connection parameter.

oactool --test-connection
Connected to the Smart Suite Database
    SD version: 4.5.0588.3901
General Settings Notification:
    Nobody expects ....
    the SPANish INQuisition

Running the Orphaned Attachment Cleanup tool

With the configuration in place, running the program to create a report is simple.

oactool
2024-11-08 11:37:22,622 INFO oac.processing.entry_point: started
2024-11-08 11:37:22,638 INFO oac.database.open_smartsuite_database: connected to database - version 4.5.0588.3901
2024-11-08 11:37:24,872 INFO oac.database.create_oactool_database: schema created
2024-11-08 11:37:24,888 INFO oac.processing.entry_point: cutoff at 20241108203724 from 2024-11-08 20:37:24.888544+01:00
2024-11-08 11:37:24,888 INFO oac.database.process_attachments: started
2024-11-08 11:37:24,904 INFO oac.database.process_attachments: retrieved 31 attachments
2024-11-08 11:37:24,904 INFO oac.database.process_attachments: finished
2024-11-08 11:37:24,904 INFO oac.oacftp.process_target_folder: started
2024-11-08 11:37:27,044 INFO oac.oacftp.process_entity_folder: processing folder "//EmailSC" - entity "E-mail Service Call"
2024-11-08 11:37:29,341 INFO oac.oacftp.process_entity_folder: processing folder "//HistoryLineIncident" - entity "History line Incident"
2024-11-08 11:37:31,669 INFO oac.oacftp.process_entity_folder: processing folder "//HistoryLineServicecall" - entity "History line Service call"
2024-11-08 11:37:34,638 INFO oac.oacftp.process_entity_folder: processing folder "//Incident" - entity "Incident"
2024-11-08 11:37:37,107 INFO oac.oacftp.process_entity_folder: processing folder "//Servicecall" - entity "Service call"
2024-11-08 11:37:39,669 INFO oac.oacftp.process_target_folder: finished
2024-11-08 11:37:39,700 INFO oac.processing.entry_point: Writing results to: C:\temp\SISpy\work\oactool\oactool.20241108193722.txt
2024-11-08 11:37:39,700 INFO oac.database.attachments_without_entities: Found: 0
2024-11-08 11:37:39,700 INFO oac.database.attachments_without_files: Found: 0
2024-11-08 11:37:39,700 INFO oac.database.files_without_attachments: Found: 0
2024-11-08 11:37:39,716 INFO oac.database.empty_attachments: Found: 0
2024-11-08 11:37:39,716 INFO oac.processing.entry_point: finished

The report can be found in the work folder, in this case C:\temp\SISpy\work\oactool.
The name includes a datetime stamp in format YYYYMMDDhhmmss.

The logging shows that there is a cutoff, attachment uploaded after the cutoff datetime are not taken into account, and that the REP_ATTACHMENT table had 31 entries. It also shows the entity folders it finds on the Attachment server. The discovered information from the attachments and files are stored and processed. The results are written in the report, with a summary in the logging output.

Example oactool output

Example oactool output

Orphaned Attachments Cleanup

After the diagnostics run, and review of the report, one can proceed to remove the orphaned attachments. The orphaned attachments are files on the attachment server without an entry in the REP_ATTACHMENTS table. The When the Smart Suite application has been running for a while, gathering the details from the attachment server might take a while. Removing files from the attachment server will take time as well.

The --keep-database parameter instructs the program to skip the discovery phase and use the database it created in the previous run.
You would use the parameter in combination with the --remove-orphans parameter to speed up the removal process.

oactool --keep-database --remove-orphans
2024-11-08 12:55:29,821 INFO oac.processing.entry_point: started
2024-11-08 12:55:29,836 INFO oac.database.open_smartsuite_database: connected to database - version 4.5.0588.3901
2024-11-08 12:55:31,930 INFO oac.processing.entry_point: Writing results to: C:\temp\SISpy\work\oactool\oactool.20241108205529.txt
2024-11-08 12:55:31,930 INFO oac.database.attachments_without_entities: Found: 0
2024-11-08 12:55:31,930 INFO oac.database.attachments_without_files: Found: 0
2024-11-08 12:55:31,946 INFO oac.database.files_without_attachments: Found: 0
2024-11-08 12:55:31,946 INFO oac.database.empty_attachments: Found: 0
2024-11-08 12:55:31,946 INFO oac.database.remove_orphans: Total Removed: 0
2024-11-08 12:55:31,946 INFO oac.database.remove_orphans: Total not found/not removed: 0
2024-11-08 12:55:31,946 INFO oac.processing.entry_point: finished

Note
In the Administration console in the client, the Attachment management has a feature to remove Attachments without a corresponding file on the Attachment server. There is no function available to remove Attachments without an Entity reference or empty attachment files.

Back to top

© Copyright 2025+, PROLIN