Migrate Asset History from OP to OD as an Attachment.

Migrate Asset History from OP to OD as an Attachment.

Currently, there is no option to transfer asset history from the OP instance to the OD instance. As a workaround, a Python script is used to retrieve the asset history, generate it as a readable PDF, and upload the PDF as an attachment to the corresponding asset in the OP instance. The attachment is then migrated along with the asset during the OP-to-OD migration.


The script requires the following configurations in the `config.json` file:
1.Application URL – Used to access the application and invoke the asset API.

2.API Key – Used for authentication while invoking the asset API and uploading the attachments.

3.Database Type – Specifies the database type to be used for executing the required queries.


Asset history data is retrieved from the `CIHistory` table, while resource state and ownership history are retrieved from the `ResourceStateHistory` and `ResourceOwnerHistory` tables, respectively.The `CIHistory` data and ownership history are generated as separate PDF files and uploaded as attachments to the corresponding asset. These attachments are then migrated along with the asset during the OP-to-OD migration.


Info
Required Packages to run the script:
Notes
weasyprint: For generating PDF files from HTML content.
requests: For making HTTP API requests.

Command to Install the Packages :
Windows:
pip install weasyprint requests

Linux:
pip install weasyprint requests
sudo apt update
sudo apt install -y libpango-1.0-0 libpangoft2-1.0-0 libpangocairo-1.0-0 libcairo2

Sample History PDF will be attached for referrence.

                    New to ADSelfService Plus?

                      • Related Articles

                      • Asset Ownership History Report

                        Please use the below query to get the report on Asset Ownership History. SELECT r.resourcename AS "Workstation Name", ct.componenttypename AS "Product type", rs.displaystate AS "Asset State", aa.first_name AS "Assigned User", LONGTODATE(sh.starttime) ...
                      • Query to show Asset state history ( MSSQL)

                        Tested in MSSQL build (14306) SELECT res.resourcename 'Asset Name', res.assettag 'Asset Tag',res.serialno 'Asset Serial No.', rs2.statedesc 'Previous State',rs1.statedesc 'Current State',DATEADD(s,DATEDIFF(s,GETUTCDATE() ,getdate()) + ...
                      • Query to retrieve users login and logout history and find their current status

                        REQUIREMENT: To generate a report that contains the login and logout history of users and to determine the current user status. TESTED IN: Builds 14503 (Postgres) QUERY 1: The following query provides the login and logout history of users. SELECT ...
                      • AntisamyNotificationSchedule - Move Notification Description as Attachment

                        Large content (>64k) in notificationtodescription table causes failure in backup/trimmed backup. The schedule's (AntisamyNotificationSchedule) job is to move large content from notificationtodesc table as attachment. Below is the file attached to ...
                      • Hide Asset

                        Use case If Technicians want to hide Asset field during template loading, then the same can be achieved using Execute Script option in Field and Form Rules. Solution Edit the incident/service template from which the asset needs to be hidden, choose ...