|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > Event Scripts > Revision > OnCheckIfMajorRev.LST script file |
It must be programmed so to check if a revision is to be considered major or minor.
In some cases, where
•the workflow module is activated
•the current document is not submitted to the Workflow process (e.g. when the revision is a MINOR one)
this script is invoked to determine if the revision is a minor revision or a major one.
If minor, the revision CAN be approved without any check from the workflow;
if major, the revision can be approved only when the workflow has been completed and approved.
Options→Environment→Workflow
or
Options→Revisions→Outputs
@REVISION |
a string containing the revision of the document being processed |
|---|---|
@UNIQUE_ID |
the unique id of the document being processed |
@OKMAJORREV |
0:is a minor revision |
|---|---|
@OKSHOWWORKFLOWMENU |
Optional. |
Lets see in details output parameters cases:
Parameter values |
Effect |
|---|---|
@OKMAJORREV = 0 |
Approve enabled and workflow menu visible |
@OKMAJORREV = 0 |
Approve enabled but no workflow menu visible |
@OKMAJORREV = 0 |
Approve enabled and workflow menu visible |
@OKMAJORREV = 1 |
No approve enabled and workflow menu visible |
.VBSCRIPT
sub main()
DBWInit(TRUE)
revision = DBWInput("@REVISION")
uniqueId = DBWInput("@UNIQUE_ID")
result = MyLogicForCheckingMajorRevisions( revision )
DBWOutput "@OKMAJORREV", result, ForWriting
end sub
'_______________________________________________________
function MyLogicForCheckingMajorRevisions( inputString )
MyLogicForCheckingMajorRevisions = 0
if inputString < "A" or inputString > "ZZZZZZZZZZZZZZZ" then
MyLogicForCheckingMajorRevisions = 0
exit function
end if
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
MyLogicForCheckingMajorRevisions = 0
else
MyLogicForCheckingMajorRevisions = 1
end if
else
MyLogicForCheckingMajorRevisions = 1
end if
end function
With the "Max num of Revision records to write as properties" option set to a number greater than zero, it is possible to create _RXX_ properties only for the Major Revisions, by enabling this new option for using the OnCheckIfMajorRev.LST script.
The OnCheckIfMajorRev.LST receives now as input a new parameter @CONTEXT with value "WRITE_RXX_MAJOR_REVISION_PROPERTY".
After the @OKMAJORREV output parameter, the OnCheckIfMajorRev.LST can now output also a sequence like:
...
@OVERRIDE_REVISIONS_FIELDS
MY_REV_FIELD_1=<REVISIONS.MY_REV_FIELD_1 value>
MY_REV_FIELD_2=<REVISIONS.MY_REV_FIELD_2 value>
...
If MY_REV_FIELD_1 is of type 'datetime' (example MY_REV_FIELD_DATE), so with the suffix _DATE in its name, the value must be outputted in the format YYYY/MM/DD
2013/02/13
After the marker @OVERRIDE_REVISIONS_FIELDS, any field name on the left side must match one of the field names declared in the Options→Revisions→Revision Fields to Write as Properties list.
For each of the above fields, the script can force a specific value to be returned (and so populating consequently the _RXX_ properties with such value).
The latest revision, approved or not approved, is ALWAYS inserted and it's in the first row of properties, no matter if it is a minor or major revision.
if the past approved revisions are 00,01,A,02,03,B,04,05,C and the current revision is 06, by enabling the OnCheckIfMajorRev script, the _RXX_ properties will be populated as:
_R01_REVISION 06
_R02_REVISION C
_R03_REVISION B
_R04_REVISION A
Creating now a new major revision "D" and approving it, the _RXX_ properties will change as:
_R01_REVISION D
_R02_REVISION C
_R03_REVISION B
_R04_REVISION A
the following output:
@OKMAJORREV=1
@OVERRIDE_REVISIONS_FIELDS
DESCRIPTION=My overridden description
for the specific document revision, it will override the REVISIONS::DESCRIPTION value with the value 'My overridden description'
Because of an internal optimization (to keep it very light due to the number of execution it has to perform), the command DBWQueryByUid is not suitable to be used in this script.
As workaround you can use another lib function named DBWGetStringFieldData
So this code
ShowDesc = DBWQueryByUid(docUid,"DESCRIPTION")
must be changed in
OkDesc = DBWGetStringFieldData("@USEDEFAULTDATASOURCE", "DOCUMENT", "DESCRIPTION", "UNIQUE_ID", docUid, ShowDesc)