OnCustomQueryTab_<TabLabel>.LST script file

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Special Scripts > User Interface >

OnCustomQueryTab_<TabLabel>.LST script file

Description

This family of scripts allows to show custom tabs in the TreePage grid:

OnCustomQueryTab

To create a custom Tab you've to create a script file named OnCustomQueryTab_<TabLabel>.LST and make it outputs the SQL query for filling the grid with results.

In the picture please note that both SimilarLength and Attachments are custom tabs.

Location

LST folder

Inputs

@IS_TAB_ACTIVATION

1: the tab has been just activated
0: the tab has been simply requeried

Outputs

@QUERY

A valid SQL query whom results will fill the grid

@HIDDEN_FIELDS

Comma separated list of fields to be hidden in the results grid

Example1

This script (that you can find in LST\DEMO_LST\ folder and you've to copy in LST\ to enable) displays the attachments currently related to the selected document and added by the RMB command Add an Attachment....

.VBSCRIPT

sub main()
 DBWInit(TRUE)
 'the parent document unique id
 documentUniqueId = DBWInput("@DOCUMENT_UNIQUE_ID")
 'to be used for revision-dependent attachments ; still not supported
 documentRevision = DBWInput("@DOCUMENT_REVISION")
 if documentUniqueId = 0 then
  exit sub
 end if
 nameFieldT = DBWLookUp("NAME_FIELD_T")
 nameFieldDESCRIPTION = DBWLookUp("NAME_FIELD_DESCRIPTION")
 nameFieldFILE_NAME = DBWLookUp("NAME_FIELD_FILE_NAME")
 nameFieldFILE_DIRECTORY = DBWLookUp("NAME_FIELD_FILE_DIRECTORY")
 nameFieldDOCUMENT_UNIQUE_ID = DBWLookUp("NAME_FIELD_DOCUMENT_UNIQUE_ID")
 'build the tab query
 query =_
  "SELECT " &_
   nameFieldT & "," &_
   nameFieldDESCRIPTION & "," &_
   nameFieldFILE_NAME & "," &_
   nameFieldFILE_DIRECTORY & "," &_
   nameFieldDOCUMENT_UNIQUE_ID &_
  " FROM DBW_ATTACHMENTS WHERE " &_
   nameFieldDOCUMENT_UNIQUE_ID & "=" & documentUniqueId
 'return the query to DBWorks
 DBWOutput "@QUERY",query,ForWriting
end sub

Example2

In the above picture is shown a Tab called SimilarLength that's generated by the script OnCustomQueryTab_SimilarLength.LST.
This script returns a list of records that has a length similar to the selected record.

.VBSCRIPT

sub main()
 DBWInit(TRUE)
 uid = DBWInput("@DOCUMENT_UNIQUE_ID")
 if uid = 0 then
  exit sub
 end if
 length = DBWQueryByUId(uid, DBWLookUp("NAME_FIELD_LENGTH"))
 if (length = "") Or (length="0") Or IsNull(length) then
  exit sub
 end if
 lengthMax = length * 1.1
 lengthMin = length * 0.9
 query = _
  "SELECT "&_
   DBWLookUp("NAME_FIELD_T") & "," &_
   DBWLookUp("NAME_FIELD_ID") & "," &_
   DBWLookUp("NAME_FIELD_LENGTH") &_
   ",*" &_
  "FROM " &_
   DBWLookUp("NAME_DOCUMENT_TABLE") &_
  " WHERE " &_
   DBWLookUp("NAME_FIELD_LENGTH") & ">=" & lengthMin &_
  " AND " &_
   DBWLookUp("NAME_FIELD_LENGTH") & "<=" & lengthMax &_
  ";"
 'return the query to DBWorks
 DBWOutput "@QUERY",query,ForWriting
end sub

Example3

The following example shows how to hide the FILE_NAME and FILE_DIRECTORY from the LST\OnCustomQueryTab_Attachements.LST script:

.VBSCRIPT

sub main()
 DBWInit(TRUE)
 'the parent document unique id
 documentUniqueId = DBWInput("@DOCUMENT_UNIQUE_ID")
 'to be used for revision-dependent attachments; still not supported
 documentRevision = DBWInput("@DOCUMENT_REVISION")
 if documentUniqueId = 0 then
  exit sub
 end if
 nameFieldT   = DBWLookUp("NAME_FIELD_T")
 nameFieldDESCRIPTION  = DBWLookUp("NAME_FIELD_DESCRIPTION")
 nameFieldFILE_NAME  = DBWLookUp("NAME_FIELD_FILE_NAME")
 nameFieldFILE_DIRECTORY  = DBWLookUp("NAME_FIELD_FILE_DIRECTORY")
 nameFieldDOCUMENT_UNIQUE_ID = DBWLookUp("NAME_FIELD_DOCUMENT_UNIQUE_ID")
 'build the tab query
 query =_
  "SELECT " &_
   nameFieldT & "," &_
   nameFieldDESCRIPTION & "," &_
   nameFieldFILE_NAME & "," &_
   nameFieldFILE_DIRECTORY & "," &_
   nameFieldDOCUMENT_UNIQUE_ID &_
  " FROM DBW_ATTACHMENTS WHERE " &_
   nameFieldDOCUMENT_UNIQUE_ID & "=" & documentUniqueId
 'return the query to MechworksPDM
 DBWOutput "@QUERY",query,ForWriting
 DBWOutput "@HIDDEN_FIELDS",nameFieldFILE_NAME & "," & nameFieldFILE_DIRECTORY,ForAppending
end sub