BlueCielo Meridian Enterprise 2012 Developer's Guide | BlueCielo ECM Solutions

Understanding the AMScriptTask extension

The sample task extension is invoked by executing the Simple Task custom command from the document context menu in PowerUser. The VBScript for this command (SimpleTask_Execute) creates a new Task object, sets values for the FunctionName and Data parameters that are predefined in the task extension, then submits the task to the task server, designated for processing by the AMSimpleTask task of the AMScriptTask task extension.

The value of the FunctionName parameter is set to the VBScript general procedure named TestScriptTask that will perform the property update when it is called from the task server. The value of the Data parameter is set to a simple string value to demonstrate how data can be passed from VBScript to the task server and back again for storage in a vault property.

Following is the Simple Task command VBScript code:

Sub SimpleTask_Execute(Batch)
    'This command execute separate task for each document in batch
    Dim t
    Set t = Vault.Task
   
    'Clean up all previouse data before submitting new task
    t.Reset
   
    '"FunctionName" and "Data" are predefined arguments
    'Set script sub or function name
    t.Set "FunctionName", "TestScriptTask"
   
    'Set script sub or function data - single argument value
    t.Set "Data", "SimpleTask Data"
       
    'Submit task with ProgID to be executed in context of current document
       t.Submit "AMScriptTask.AMSimpleTask", Document
End Sub

The task server receives the Task object, identifies it for processing by the AMScriptTask task extension and passes the object to the extension for processing. The AMScriptTask task extension receives the Task object and calls the AMSimpleTask class procedures to set the values of the FunctionName and Data parameters.

The task’s Execute procedure then calls the VBScript procedure TestScriptTask along with the Data value that was passed to the task. The TestScriptTask procedure updates the current document’s String property with the current date and time with the value of the Data parameter appended.

Following is the TestScriptTask VBScript code:

Sub TestScriptTask( Data )
    Document.String = CStr(Vault.ServerTimeGMT) + " " + CStr(Data)
End Sub

Taking the sample one step further, the ScriptTasks.met file also contains a custom command named Batch Task that performs the same functions as Simple Task but on a batch of documents. It does this by first creating one new Task object with the same parameters as Simple Task. Then it creates a new parameter containing the ordinal number of each document in the batch along with its document ID. This is done so that the task extension can create a collection of documents IDs from which it can make repeated calls back to the TestScriptTask procedure for each document in the batch. Before it terminates, Batch Task submits the new task to the task server for processing.

For further details on how the AMScriptTask task extension works, refer to the source code provided.


Copyright © 2000-2012 BlueCielo ECM Solutions

www.bluecieloecm.com