OnFilterRev.LST script file

<< Click to Display Table of Contents >>

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

OnFilterRev.LST script file

Description

It decides if a released document must be copied in the released database (addressed by the data source DBWORKS_RELEASED) or not.

Activation

Options→Environment→Release Database Mode

Input

@UNIQUE_ID

the unique id of the processed document

@REVISION

a string containing the revision of the document being processed

Output

@OKREV

0: don't copy the record in the released database
1: copy the record in the released database

Remarks

A typical usage of this script is to filter out minor revisions, so having only major revisions to populate the DBWORKS_RELEASED database. Of course, since the unique id of the document is passed to the script, also more sophisticated criterias can be implemented ( based, for example, on particular attributes of the document ).

Example

Suppose we want to pass to the DBWORKS_RELEASED database only revisions without a dot ( . ) character ( major revisions like A, B, C, … ) and so avoiding minor revisions ( like A.1, A.2, B.3 ) to be inserted in the released database. A script filtering with the above role could be the following:

.VBSCRIPT

Sub Main()
 DBWInit(TRUE)
 revision = DBWInput("@REVISION")
 uniqueId = DBWInput("@UNIQUE_ID")
 DBWOutput "@OKREV", MyLogicForFilteringRevision( revision ), ForWriting
end sub
function MyLogicForFilteringRevision( inputString )
 MyLogicForFilteringRevision = 0
 if left(inputString,1) = "." then
  inputString = "0" & inputString
 end if
 tokens = Split( inputString, ".", 2, 1)
 if ubound( tokens ) = 1 then
  l = Len( tokens(1) )
  if l>0 then
   MyLogicForFilteringRevision = 0
  else
   MyLogicForFilteringRevision = 1
  end if
 else
  MyLogicForFilteringRevision = 1
 end if
end function