|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > Event Scripts > Document > OnAddDocument.LST script file |
This script is executed every time a new document is added using the function AddDocument (from both the UI and the AddDocument shell command).
LST folder
Options→General→More...→
Use OnAddDocument.LST script when adding a document
@DOCUMENT_PATHNAME |
the full path name of the document to be added; |
|---|---|
@PARENT_UNIQUE_ID |
the unique id of the parent document to which the generic document will be added as child |
@OKADDDOC |
0: fail |
|---|---|
@OKDATA |
0: display 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 |
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