|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > Event Scripts > Revision > OnOKRev.LST script file |
This script is executed when the user presses the OK button in the Revision Data Input Form. It receives as input all the field values, then returns @OKDATAREV variable.
Options→Revisions
any field name |
|
|---|---|
@EDIT |
0: insert a new record |
@REVISION_ACTION |
Gets the code of the current action done on the revision; the codes are: 0 Record editing 1 New Revision |
@REVISION_APPROVAL_TYPE |
if @REVISION_ACTION=2, gets the code of the type of approval made for the current revision; the codes are : 0 approve to next revision 1 approve to previous revision |
@REVISION_ROLLBACK_NAME |
if (@REVISION_ACTION=3 OR @REVISION_ACTION=2) AND @REVISION_APPROVAL_TYPE=1, |
@REVISION_SELECTED |
if @REVISION_ACTION=3 or 4, it contains the value of the revision on which the action, indicated in the @REVISION_ACTION parameter, is applied LIMITATION: the OnOkRev.LST script is called only if the REVISION table record is edited, so the @REVISION_ACTION=4 ( visualization ) will not be managed when the record is opened in VIEW mode. |
@PARENT_WINDOW_TITLE |
the title of the window the script has been called from |
@PARENT_WINDOW_HANDLE |
the handle (long integer) of the window the script has been called from |
@REVISION_PHASE |
this variable is passed if not null only; Remarks
|
A drawing saves its own record and that ones of the document being saved.
When saving the drawing's own record
DRAWING_UNIQUE_ID |
drawing unique id |
|---|---|
DOCUMENT_UNIQUE_ID |
0 |
When saving any drawn document's record
DRAWING_UNIQUE_ID |
drawing unique id |
|---|---|
DOCUMENT_UNIQUE_ID |
part/assembly unique id |
@OKDATAREV |
0: avoid validation |
.VBSCRIPT
Sub main()
DBWInit(TRUE)
' action = 0 Record editing
' action = 1 New Revision
' action = 2 Revision Approved
' action = 3 Revision Activated
' action = 4 Revision Visualized
action = DBWInput("@REVISION_ACTION")
' approvalType = 0 if action=2, approve to next revision
' approvalType = 1 if action=2, approve to previous revision
approvalType = DBWInput("@REVISION_APPROVAL_TYPE")
' if not empty and action = 3, rollback revision name
rollbackName = DBWInput("@REVISION_ROLLBACK_NAME")
DBWMsgBox _
"action=" & action & vbcrlf &_
"approvalType=" & approvalType & vbcrlf &_
"rollbackName=" & rollbackName
DBWOutput "@OKDATAREV",1,ForWriting
End Sub
another example: the approval of a document will be confirmed only if a field (DESCRIPTION2) contains a specific value ("yes")
.VBSCRIPT
Sub main()
DBWInit(TRUE)
action = DBWInput("@REVISION_ACTION")
uid = DBWInput("DOCUMENT_UNIQUE_ID")
desc2 = DBWQueryByUid(uid,"DESCRIPTION2")
if action = 2 Then 'action = 2 Revision Approved
If UCase(desc2) = "YES" Then
DBWMsgBox "APPROVED"
DBWOutput "@OKDATAREV",1,ForWriting
Else
DBWMsgBox "REJECTED"
DBWOutput "@OKDATAREV",0,ForWriting
end If
Else
DBWOutput "@OKDATAREV",1,ForWriting
End if
End sub
another example: the approval is not allowed if called from standalone client instead of a CAD integration
.VBSCRIPT
Sub main()
DBWInit(TRUE)
action = DBWInput("@REVISION_ACTION") 'action = 2 Revision Approved
If action=2 Then ' it's an approval action
If UCase(DBWorksCADApplicationName)="STANDALONE" Then 'calling app is standalone client
DBWMsgbox2 "approval from Standalone Client is not allowed;" & "please approve from CAD integration instead"&,16,"onokrev.lst"
DBWOutput "@OKDATAREV",0,ForWriting
Else 'approval from CAD - go on
DBWOutput "@OKDATAREV",1,ForWriting
End If
Else 'it isn't an approval action
DBWOutput "@OKDATAREV",1,ForWriting
end if
End sub