0

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
AliJH
  • 1
  • 3

3 Answers3

0

I found in a obscure API document from OpenText that you could set the property FILE_EXTENSION. I got the same issue and it fixed it. So in your case it should be

  $doc.SetProperty("FILE_EXTENSION", $appid)

Though you mention you tried it, it worked in my case.

Niels V
  • 1,005
  • 8
  • 11
-1

The short answer is that you cannot change the file extension.

When you upload a file, the fileextension is uses to choose the application on the profile. In DM531/DM10 each application can have one default extension (DOCX or DOC for word), then you have to log on to the CyberDocs to add other file extensions. The extensions are added to the table APP_FILE_EXTNS note that you cannot add rows since the system_id is generated by the eDOCS API. The system_id is created using the sequence tables SEQ_xxx. The applications is in the APPS table.

So you have to ask your eDOCS DM admin to add the needed file extensions using the Library Maintenance or the DM Management Studio tool (DM10 or DM 16.x).

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • Thank you so much for taking the time to reply. I've updated my original post with additional details. We have a number of extensions defined in the APP_FILE_EXTNS table but I'm not having any luck working out how to take advantage of them via the DM API. Any advice you can offer on that front would be greatly appreciated. – AliJH Sep 24 '17 at 22:45
-1

I am not sure if this will be helpful but I have found this code below where the extension is set.

            Function ahtCommonFileOpenSave( _
            Optional ByRef flags As Variant, _
            Optional ByVal InitialDir As Variant, _
            Optional ByVal Filter As Variant, _
            Optional ByVal FilterIndex As Variant, _
            Optional ByVal DefaultExt As Variant, _
            Optional ByVal FileName As Variant, _
            Optional ByVal DialogTitle As Variant, _
            Optional ByVal hwnd As Variant, _
            Optional ByVal OpenFile As Variant) As Variant

                ' This is the entry point you'll use to call the common
                ' file open/save dialog. The parameters are listed
                ' below, and all are optional.
                '
                ' In:
                ' Flags: one or more of the ahtOFN_* constants, OR'd together.
                ' InitialDir: the directory in which to first look
                ' Filter: a set of file filters, set up by calling
                ' AddFilterItem. See examples.
                ' FilterIndex: 1-based integer indicating which filter
                ' set to use, by default (1 if unspecified)
                ' DefaultExt: Extension to use if the user doesn't enter one.
                ' Only useful on file saves.
                ' FileName: Default value for the file name text box.
                ' DialogTitle: Title for the dialog.
                ' hWnd: parent window handle
                ' OpenFile: Boolean(True=Open File/False=Save As)
                ' Out:
                ' Return Value: Either Null or the selected filename

                Dim OFN As tagOPENFILENAME
                Dim strFilename As String
                Dim strFileTitle As String
                Dim fResult As Boolean

                ' Give the dialog a caption title.
                If IsMissing(InitialDir) Then InitialDir = CurDir
                If IsMissing(Filter) Then Filter = ""
                If IsMissing(FilterIndex) Then FilterIndex = 1
                If IsMissing(flags) Then flags = 0&
                If IsMissing(DefaultExt) Then DefaultExt = ""
                If IsMissing(FileName) Then FileName = ""
                If IsMissing(DialogTitle) Then DialogTitle = ""
                If IsMissing(OpenFile) Then OpenFile = True

                ' Allocate string space for the returned strings.
                strFilename = Left(FileName & String(256, 0), 256)
                strFileTitle = String(256, 0)

                ' Set up the data structure before you call the function
                With OFN
                    .lStructSize = Len(OFN)
                    .hwndOwner = hwnd
                    .strFilter = Filter
                    .nFilterIndex = FilterIndex
                    .strFile = strFilename
                    .nMaxFile = Len(strFilename)
                    .strFileTitle = strFileTitle
                    .nMaxFileTitle = Len(strFileTitle)
                    .strTitle = DialogTitle
                    .flags = flags
                    .strDefExt = DefaultExt
                    .strInitialDir = InitialDir
                    ' Didn't think most people would want to deal with
                    ' these options.
                    .hInstance = 0
                    .strCustomFilter = ""
                    .nMaxCustFilter = 0
                    .lpfnHook = 0
                    'New for NT 4.0
                    .strCustomFilter = String(255, 0)
                    .nMaxCustFilter = 255
                End With

                ' This will pass the desired data structure to the
                ' Windows API, which will in turn it uses to display
                ' the Open/Save As Dialog.

                If OpenFile Then

                    fResult = aht_apiGetOpenFileName(OFN)

                Else

                    fResult = aht_apiGetSaveFileName(OFN)

                End If

                ' The function call filled in the strFileTitle member
                ' of the structure. You'll have to write special code
                ' to retrieve that if you're interested.

                If fResult Then
                    ' You might care to check the Flags member of the
                    ' structure to get information about the chosen file.
                    ' In this example, if you bothered to pass in a
                    ' value for Flags, we'll fill it in with the outgoing
                    ' Flags value.
                    If Not IsMissing(flags) Then
                        flags = OFN.flags
                    End If

                    ahtCommonFileOpenSave = TrimNull(OFN.strFile)

                Else

                    ahtCommonFileOpenSave = vbNullString

                End If

            End Function