OnGetWorkflowProcess.LST script file

<< Click to Display Table of Contents >>

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

OnGetWorkflowProcess.LST script file

Description

With the script it's possible to bypass the SQL-query based Process assignment (defined in the DBWorkflowDef.txt workflow definition file) and to assign the process by using rules and methods not simply defineable by an SQL-query.

Activation

Options→Environment→Workflow

Input

@DOCUMENT_UNIQUE_ID

unique id of the document to be submitted to the workflow

@WORKFLOW_AVAILABLE_PROCESS

list of the available processes, as defined in DBWorkflowDef.txt

@SILENT

0: default usage
1: DBWorks/DBInventor requests to return the process without any user interaction

Output

@WORKFLOW_ASSIGNED_PROCESS

name of the process to be assigned to the document

@OK

0: stops the worflow process
1: go on with the worflow process

Remarks: if no output is sent back to DBWorks, then the standard process assignment way is used ( with the SQL-query defined in the DBWorkflowDef.txt )

Example

This example shows how to read the list of available processes, and how to assign a process, based on a rule ( in this case the rule is that if the field CATEGORY1 contains the values 'Cube' or 'Cylinder', then the process is the MODELS )

.VBSCRIPT

sub main()
 DBWInit(TRUE)
 docUid = DBWInput("@DOCUMENT_UNIQUE_ID")
 Redim processes(1)
 readAvailableWorkflowProcesses processes
 theProcesses = ""
 for i = 0 to ubound(processes)
  theProcesses = theProcesses + vbcrlf + processes(i)
 next
 'DBWMsgBox "docUid = " & docUid & vbcrlf & vbcrlf & "Available processes: " & vbcrlf & theProcesses
 category1 = DBWQueryByUid( docUid, "CATEGORY1" )
 if category1 = "Cube" or category1 = "Cylinder" then
  DBWOutput "@WORKFLOW_ASSIGNED_PROCESS","MODELS",ForWriting
 end if
end sub

 

sub readAvailableWorkflowProcesses( processes )

 Set fs = CreateObject("Scripting.FileSystemObject")
 Set tfolder = fs.GetSpecialFolder(TemporaryFolder)
 Set a = fs.OpenTextFile( tfolder & "\" & "dbwscrpt.in" , ForReading, True )
 k=0
 Dim tokens
 Do While a.AtEndOfStream <> True
  line = a.ReadLine
  tokens = Split( line, "=", 2, 1)
  if tokens(0) = "@WORKFLOW_AVAILABLE_PROCESS" then
   k = k+1
   Redim preserve processes(k)
   processes(k-1) = tokens(1)
  end if
 Loop
 a.Close
end sub