OnDrop.LST script file

<< Click to Display Table of Contents >>

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

OnDrop.LST script file

Description

This script is fired when dropping a set of files/documents on a target document.

Activation

Options→General→More

Input

@DROP_TARGET_UNIQUE_ID

the drop target document unique ID

@DROP_PROJECT_UNIQUE_ID

the project unique ID

@IS_DROP_FILES

0: a drop of existing database documents is executed
1: a drop of external files (typically from Windows Explorer) is executed

@IS_DROP_MOVE

1: the drop will detach the documents from their original parents
0: otherwise

@DROP_FILE_PATH

Available only when @IS_DROP_FILES = 1
the full path of a file being dropped

@DROP_DOCUMENT_UNIQUE_ID

Available only when @IS_DROP_FILES = 0
the document unique id to be dropped

@DROP_PARENT_UNIQUE_ID

Available only when @IS_DROP_FILES = 0
The parent unique id of the document to be dropped

Output

@OKDROP

0:don't allow drop
1: allow drop

Example

.VBSCRIPT

sub main()
 DBWInit(TRUE)
 dropTargetUid = DBWInput("@DROP_TARGET_UNIQUE_ID")
 projectUid = DBWInput("@DROP_PROJECT_UNIQUE_ID")
 isDropFiles = DBWInput("@IS_DROP_FILES")
 isDropMove = DBWInput("@IS_DROP_MOVE")
 allFilesPaths = ""
 allDocUids = ""
 allParentUids = ""
 Set fs = CreateObject("Scripting.FileSystemObject")
 Set tfolder = fs.GetSpecialFolder(TemporaryFolder)
 Set a = fs.OpenTextFile( tfolder & "\" & "dbwscrpt.in" , ForReading, True )
 Dim tokens
 Do While a.AtEndOfStream <> True
  line = a.ReadLine
  tokens = Split( line, "=", 2, 1)
  if isDropFiles = "1" then
   if tokens(0) = "@DROP_FILE_PATH" then
    filePath = tokens(1)
    allFilesPath = allFilesPath & vbcrlf & filePath
   end if
  else
   docUid = 0
   parentUid = 0
   if tokens(0) = "@DROP_DOCUMENT_UNIQUE_ID" then
    docUid = tokens(1)
    allDocUids = allDocUids & vbcrlf & docUid
   elseif tokens(0) = "@DROP_PARENT_UNIQUE_ID" then
    parentUid = tokens(1)
    allParentUids = allParentUids & vbcrlf & parentUid
   end if
  end if
 Loop
 a.Close
 if isDropFiles then
  DBWMsgBox "The files:" & vbcrlf & allFilesPath & vbcrlf & vbcrlf & "will be dropped in document:" & vbcrlf & vbcrlf & dropTargetUid
 else
  DBWMsgBox "The documents:" & vbcrlf & allDocUids & vbcrlf & vbcrlf & "with parents: " & vbcrlf & allParentUids & vbcrlf & vbcrlf & "will be dropped in document:" & vbcrlf & vbcrlf & dropTargetUid
 end if
 DBWOutput "@OKDROP","1",ForWriting
end sub