Bit of a long shot but I haven't had any luck finding the answer documented anywhere.
I'm writing a custom tool using the eDOCS DM API to bulk upload files into eDOCS. The tool almost works as intended, I create a task list of files and metadata properties and it create the required eDOCS profiles and saves the files.
Saving a file into eDOCS is essentially a two step process:
Step 1 - create a document profile form This is done by creating a DM API object with Key/Value pairs to set the fields on the form. One of these fields links the document to a particular application (e.g. MS Word, Excel etc) which has a default extension. When the profile has been created an empty file is generated in the eDOCS file repository with a random file name and the default extension of the linked application.
Step 2 - save the document to the repository This is straightforward enough, essentially read the source file into a byte array and use an eDOCS DM API object to write the stream to the file (created in step 1) held in the eDOCS file repository.
What I'm struggling with is changing the extension of the file generated in the eDOCS file repository when the form is created. I haven't been able to find any pointers in the official documentation or any answers online (though I have found someone else asking this question on Spiceworks a couple of years ago (https://community.spiceworks.com/topic/196865-open-text-edocs-hummingbird-support-group?page=2#entry-5226944)).
So a practical example a rtf file is saved into eDOCS using this tool and associated with Microsoft Word, as the default extension for Microsoft Word is set to docx the file is saved with extension docx and when retrieved by a user Word fails to interpret the file and throws an error message.
When saving files individually using the standard eDOCS DM Extensions program there is a 'Save as' field available which lets you override the default file extension.
The only way I can think of to work around this issue at the moment is to create an entry in the eDOCS Database Applications table for every file extension we encounter however I'm hoping there is a way to solve this issue using the provided API.
Any advice would be greatly appreciated, thank you.
Additional Info: So we have multiple extensions defined for each application in the APP_FILE_EXTNS table, as an example I've included some of the rows that relate to Microsoft Word below:
APPS_LINK LANGUAGE EXTENSION FILE_FORMAT DESCRIPTION NEW_DOC_ONLY ORDER_NO DISABLED
1435 EN docx NULL Word Document (*.docx) N 1 N
1435 EN DOT NULL Word 97-2003 Template (*.dot) N 13 N
1435 EN doc NULL Word 97-2003 Document (*.doc) N 2 N
1435 EN rtf 6 Rich Text Format (*.rtf) N 8 N
And below is an example API call (using Powershell) to create a profile:
$doc = New-Object -ComObject PCDClient.PCDDocObject.1
$doc.SetDST($global:dmDST)
$doc.SetObjectType($global:dmForm)
$doc.SetProperty("PD_FILEPT_NO", $edocsFilePart)
$doc.SetProperty("DOCNAME", $docname)
$doc.SetProperty("APP_ID", $appid)
$doc.SetProperty("AUTHOR_ID", $author
$doc.SetProperty("TYPIST_ID", $typist
$doc.SetProperty("TYPE_ID", "DEFAULT")
$doc.SetProperty("%TARGET_LIBRARY", $global:dmLibrary)
$doc.Create()
# use PCDClient.PCDPutDoc and PCDClient.PCDPutStream to save the file to the edocs file repo
# unlock the document
So in the above example $appid will relate to the APPLICATION column in the APPS table (e.g. MS WORD, FOLDER, PDF, etc). When $doc.Create() is called the following happens:
- document profile is created
- empty file on the edocs file repo is created with extension set to the default extension of the application set via $doc.SetProperty("APP_ID", $appid)
- COMPONENTS table is updated to link the empty file to the document profile
Do you know if there is a way using the DM API to take set the file extension to one of the non-default extensions for the application associated with the document?
I've tried PCDClient.PCDDocObject.SetProperty() with a few different keys all of which have failed:
- EXTENSION
- %EXTENSION
- EXT
- %EXT
- PATH
- %PATH
- FILE_EXTENSION
- %FILE_EXTENSION