February 17, 2015

Extract attachments (DOCLINKS)

This post explains how to extract a set of attachments from the server.
First of all you have to find the root folder where the attachments are stored. This can be found in mxe.doclink.doctypes.defpath system property (System Configuration - Platform Configuration - System Properties).

Unfortunately, from the file names you cannot understand to which records each file is linked to. In order to do this you have to run an SQL query. In this example I'm showing how to extract all the file names of work orders attachments.

SELECT wo.wonum, di.document, di.description, di.urlname
FROM docinfo di
JOIN doclinks dl ON dl.docinfoid=di.docinfoid
JOIN workorder wo ON wo.workorderid=dl.ownerid
WHERE dl.ownertable='WORKORDER';


This ERD shows you the relationships between the DOCLINKS tables.