|
<< Click to Display Table of Contents >> Navigation: »No topics above this level« Custom scripts on the client |
Custom scripts on the client
Web Client added the ability to execute custom scripts on the client. This feature is a complement to the ability to run server side scripts.
The script is triggered by a click on a custom menu entry displayed in the contextual menu of a document, as for server side scripts.
The declaration of the command must be added to the file \Scripts\customMenus.xml and is very similar to the declaration used for server side scripts:

Add a tag command and define an attribute id that must be unique inside the file, in the example above it's 'commandID'.
The attribute english and italian indicate the caption that the menu command has on the client, depending on the current language in use.
Finally, the most important attribute is clientScript and indicates a script that must be available in the directory \Program Files\DBWORKS Stand Alone\WebViewer\Scripts. In this specific case the script name is \Program Files\DBWORKS Stand Alone\WebViewer\Scripts\myScript.vbs .
Inside the tag, the visibilityCondition determines when the command is available. Here again you can set conditions based upon the record field values, and this is the case, or set access limitations based upon the personality or group of the user. Please refer to the general topic for custom menus for more information on how to apply restrictions to custom commands.
The client downloads the script from the server and runs it. The script contains implicitly two objects that you needn't declare:
oRsdoc is a COM object of type ADODB.Recordset that contains the fields and values of the DOCUMENT table for the document that was right clicked
o· ScriptResult is an object defined and documented for server Side scripting to which a new method was added:
openURL(<url>)
where <url> is a string with a URL to be opened on the client. Note that the choice of the browser is generally left to the current settings in the client OS, and the operation is the equivalent of a double click on a Windows shortcut pointing to the URL.
An example of a valid script:

The above script, for the sake of brevity and simplicity, does only two things: it displays in a message box the value of the field ID of the record clicked and opens the web browser on the index page of MechWorks' web site .
DBWorks/DBInventor can optionally generate previews at save time from the CAD. These previews are saved as jpg and are generally better looking than standard previews.
But since these previews are only generated server side, if you check out remotely, edit and check in a CAD document its preview is not updated and this affects both Web Client users and CAD users in the design team.
You should be aware of this limitation when you enable Web Client to perform revision operations remotely.