Jaa


How to Use the Scriptor Component

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The Scriptor Scriptor component makes it possible to insert code modules into your pipeline. These modules are written using Microsoft Visual Basic Scripting Edition (VBScript). In a Scriptor component, you can access the OrderForm dictionary, access pipeline context information, create other objects, and even run other pipelines. Additionally, because the Scriptor component supports configuration parameters, the Scriptor component provides perhaps the easiest way to write custom components for the Order Processing pipeline (OPP).

When you add a Scriptor component to your pipeline, you configure the component by using the Component Properties dialog box. For more information about how to use the Component Properties dialog box, see How to Configure the Scriptor Component.

Scriptor Methods

To display the property pages for a Scriptor component, in the Pipeline Editor, select Internal, and then click Edit. The Scriptor component displays an edit window that contains the three routines that the Scriptor component can process:

''The following entry points are available (shown in VBScript format):

function MSCSExecute(config, orderform, context, flags)

    MSCSExecute = 1

end function

sub MSCSOpen(config)

end sub

sub MSCSClose()

end sub

These routines are called entry points for the Scriptor component. You can think of them as you would think of the event handlers for a Visual Basic object or an ActiveX control. You fill in the body of these routines with your own task-specific scripting code. When the OPP runs the Scriptor component, it runs the code that you write.

The script that you write for the MSCSOpen subroutine is run immediately after the Scriptor component is created. The MSCSExit subroutine is run after the Scriptor component is destroyed. The MSCSExecute function is called after the MSCSOpen subroutine, but before the MSCSExit subroutine.

Of the three exports that make up a default Scriptor component, only the MSCSExecute function is required. The parameters that the Scriptor component passes to this function include the following:

  • config. The configuration dictionary for the script, which contains the information in the following table.

    Name

    Value

    User-defined configuration parameters

    Parameter value. For example, if you type tax=1 in the Config box on the property page for the Scriptor component, the tax name/value pair appears in the Configuration dictionary.

    script_type

    Identifies whether the script is internal or external. If it is internal, script_type contains the value INTERNAL; otherwise, it contains the value EXTERNAL.

    script_text

    Contains all the script for the component.

    script_name

    Contains the fully qualified path of the file that contains the script to run. If the script_type is INTERNAL, this name/value pair does not contain a value.

    engine_prog_id

    Identifies the scripting engine used to interpret the script. Possible values are VBScript and JScript.

  • orderform. The OrderForm dictionary that you pass to the Execute method of the pipeline object.

  • context. The Context dictionary that you pass to the Execute method of the pipeline object.

  • flags. The flags that you pass to the Execute method of the pipeline object.

See Also

Other Resources

How to Configure the Scriptor Component