OnFilterUids.LST script file

<< Click to Display Table of Contents >>

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

OnFilterUids.LST script file

Description

It is executed every time DBWorks recalculates the list of related document, being the DrawingóPart Link Mode active.

The proper programming of this script permits the user to implement some rules or strategies different from those cabled in the DBWorks code, for example filtering out some documents whose identifier contains some keywords.

Activation

Options→Environment→Link Mode

Input

@DOCUMENT_UNIQUE_ID

the unique id of the processed document

@RELATED_DOCUMENTS_UID_LIST

the list of the uids of the related documents, as calculated by DBWorks>
the uids are separated by commas ( Ex: 10,20,30 )

Output

@RELATED_DOCUMENTS_UID_LIST

the filtered list of the uids that DBWorks must use>
the uids must be separated by commas ( Ex: 10,20,30 )

Example

.VBSCRIPT

Sub Main()
 DBWInit(TRUE)
 docUid = DBWInput("@DOCUMENT_UNIQUE_ID")
 uidList = DBWInput("@RELATED_DOCUMENTS_UID_LIST")
 DBWMsgBox "Doc unique id=" & docUid & vbcrlf & "Input Uid List = " & uidList
 filteredUidList = "0" 'initialize to a 0: no filters applied
 Dim tokens
 tokens = Split( uidList,",")
 for i=0 to ubound(tokens)
  uid = tokens(i)
  t = DBWQueryByUid(uid,DBWLookUp("NAME_FIELD_T"))
  id = DBWQueryByUid(uid,DBWLookUp("NAME_FIELD_ID"))
  fileName = DBWQueryByUid(uid,DBWLookUp("NAME_FIELD_FILE_NAME"))
  DBWMsgBox "Related document: " & t & " " & id & " " & fileName
  '
  ' here you should decide if the related document must be included or
  ' not in the output filtered list
  '
  ' if ... then
   if filteredUidList<>"" then
    filteredUidList = filteredUidList & ","
   end if
   filteredUidList = filteredUidList & uid
  ' end if
 next
 DBWOutput "@RELATED_DOCUMENTS_UID_LIST",filteredUidList,ForWriting
end sub