OnDeleteRecord.LST script file

<< Click to Display Table of Contents >>

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

OnDeleteRecord.LST script file

Description

It is fired when a record or a file is deleted when opening the browser for updating and choosing the Delete record deleteRecord functionality.

Activation

Options→General

Input

@DOCUMENT_UNIQUE_ID

uid of the doc

Case file deletion

@DOCUMENT_UNIQUE_ID

the first of the set of UNIQUE_IDs related to the file to be deleted

@DOCUMENT_PATH_NAME

file to be deleted

Case remove projectusers associations in the DBWArm tables

@IS_DELETE_PROJECT

it is about to be deleted any DBWArm ProjectUser association

Output

@OKDELETE

This option is used to check if the record have or not have to be deleted.
0:stop deletion
1:proceed with deletion ( default )

Remarks

The order in which checks are performed is exactely A→B→C

 

Case A : check if projects that are about to be deleted are under DBWARM control

@DOCUMENT_UNIQUE_ID

> 0

@DOCUMENT_PATH_NAME

= ""

@IS_DELETE_PROJECT

1

 

Case B : check if OK in record deletion

@DOCUMENT_UNIQUE_ID

> 0

@DOCUMENT_PATH_NAME

= ""

@IS_DELETE_PROJECT

0

 

Case C : check if OK in file deletion

@DOCUMENT_UNIQUE_ID

> 0

@DOCUMENT_PATH_NAME

""

@IS_DELETE_PROJECT

0

Example

Record deletion

.VBSCRIPT

Sub Main()
 uid = DBWInput("@DOCUMENT_UNIQUE_ID")
 ok = InputBox( "uid=" & uid & " will be deleted. Confirm ?" )
 DBWOutput "@OKDELETE",ok,ForWriting
End Sub

File deletion

.VBSCRIPT

sub main()
 uid = DBWInput("@DOCUMENT_UNIQUE_ID")
 fPath = DBWInput("@DOCUMENT_PATH_NAME")
 if fPath<>"" then
 'a file is about to be deleted
  ok = InputBox( "file: " & fPath & " will be deleted.Confirm ?" )
 else
  ok = InputBox( "uid: " & uid & " will be deleted.Confirm ?" )
 end if
 DBWOutput "@OKDELETE",ok,ForWriting
end sub

Project deletion

.VBSCRIPT

sub main()
 uniqueId = DBWInput("@DOCUMENT_UNIQUE_ID")
 isDeleteProject = DBWInput("@IS_DELETE_PROJECT")
 typ = DBWQueryByUId(uniqueId,"T")
 user_group = DBWGetUserGroup()
 if typ = "0" AND user_group = "DBWorks Default" then
  DBWOutput "@OKDELETE", "1", ForWriting
 elseif typ = "0"  then
  if isDeleteProject = "0" then
   DBWMsgBox "Only an administrator may delete a project", 16, "Access denied"
  end if
  DBWOutput "@OKDELETE", "0", ForWriting
 else
  DBWOutput "@OKDELETE", "1", ForWriting
 end if
end sub