OnAddDocument.LST script file

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Event Scripts > Document >

OnAddDocument.LST script file

Description

This script is executed every time a new document is added using the function AddDocument (from both the UI and the AddDocument shell command).

Location

LST folder

Activation

Options→General→More...→ic_checkUse OnAddDocument.LST script when adding a document

Input

@DOCUMENT_PATHNAME

the full path name of the document to be added;
please note this line will be passed as many time as the number of documents selected in the open dialog

@PARENT_UNIQUE_ID

the unique id of the parent document to which the generic document will be added as child

Output

@OKADDDOC

0: fail
1: success

@OKDATA

0: display the data input form
1: accept data without displaying the data input form

FILE_DIRECTORY

The file directory of the generic document, if a redefinition of the same is required; FILE_DIRECTORY must be localized in the current database language

FILE_NAME

The file name of the generic document, if a redefinition of the same is required; FILE_NAME must be localized in the current database language

Example

More than one document selected to be added

.VBSCRIPT

Sub main()
 Set fs = CreateObject("Scripting.FileSystemObject")
 Set tfolder = fs.GetSpecialFolder(TemporaryFolder)
 Set inputFile = fs.OpenTextFile( tfolder & "\dbwscrpt.in" , ForReading, True )
 Dim tokens
 Do While inputFile.AtEndOfStream <> True
  line = inputFile.ReadLine
  if line<>"" then
   tokens = Split( line, "=", 2, 1)
   if tokens(0) = "@DOCUMENT_PATHNAME" then
    ' do any action with tokens(0)
   end if
  end if
 Loop
 inputFile.Close
 DBWOutput "@OKADDDOC", "1",ForWriting
 DBWOutput "@OKDATA", "1",ForAppending
End Sub

Only one document selected to be added

.VBSCRIPT

Sub main()
        DBWInit(TRUE)
        fileName = DBWInput("@DOCUMENT_PATHNAME")
        parentUid = DBWInput("@PARENT_UNIQUE_ID")
        DBWMsgBox "file name=" & fileName & vbcrlf & "parent uid=" & parentUid
        DBWOutput "@OKADDDOC", "1",ForWriting
        DBWOutput DBWLookUp("NAME_FIELD_FILE_DIRECTORY"),"f:\dbworks\",ForAppending
        DBWOutput DBWLookUp("NAME_FIELD_FILE_NAME"),"advopt.txt",ForAppending
        DBWOutput "@OKDATA", "1",ForAppending
End Sub