OnNewPrj.LST script file

<< Click to Display Table of Contents >>

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

OnNewPrj.LST script file

Description

This script is executed when a new project or a new sub-project is created.

Activation

Options→Projects

Remarks

The parameter @PARENT_PROJECT_UNIQUE_ID allows to distinguish between creating a top-level project or a sub-project.

Example

.VBSCRIPT
Sub Main()
 DBWinit(TRUE)
 parentProjectUniqueId = DBWInput("@PARENT_PROJECT_UNIQUE_ID")
 if parentProjectUniqueId = 0 then 'case of a new top-level project
  res = DBWInputBox("Enter here the new project name", npn)
  if res<>0 AND npn<>"" Then
   DBWShell("CreateNewProject " & replace( npn, " ", "|", 1 ) )
  end if
 else 'case of a new sub-project
  parentProjectID = DBWQueryByUid(parentProjectUniqueId, DBWLookUp("NAME_FIELD_ID"))
  subProjectPrefix = parentProjectID & "-"
  ris = DBWInputBox1("Enter the ID for the new sub-project", subProjectPrefix, npn)
  if ris<>"" AND npn<>"" then
   DBWShell("CreateNewProject " & replace( npn, " ", "|", 1 ) & " " & parentProjectUniqueId)
  end if
 end if
 if npn<>"" then
  DBWShell("Wait")
  DBWShell("Requery")
 end if
End Sub

This example shows how to populate the entry data form with default values

.VBSCRIPT
Sub Main()
 DBWinit(TRUE)
 res = DBWInputBox("Enter the ID for the new project",newproject)
 if newproject= "" then
  exit sub
 end if
 res = DBWInputBox("Enter the machine description",strDescription)
 if strDescription = "" then
  exit sub
 else
  DBWOutput "DESCRIPTION", strDescription, ForWriting
 end if
 DBWShell("CreateNewProject " & replace( newproject, " ", "|", 1 ))
end sub