Pages

Tuesday, September 18, 2018

Find attachments in DOCLINKS for each record

This post explains how to extract the list of attachments attached to a record.

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 get 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'
    AND   wo.wonum =:wonum;

From the above query you will get the file path in urlname column. You can extract the file from the server in those path.

Note: The files will be there in the server where the webserver is installed. If there are more than one webserver and a load balancer is used to redirect to these webservers, there should be a shared folder shared between the webservers.

No comments:

Post a Comment