Home Search

DriveWorks Pro 24
How To: Use the Specification Host control (KB16122101)

Send Feedback

How To: Use the Specification Host control

This topic explains how to use the Specification Host control, including information on:

  • Passing data to the hosted specification
  • Receiving data from the hosted specification
  • Running macros in host and hosted specifications

This article discusses how to use the Specification Host control.

Dialog Forms, launched from Item Lists, Dialog or Macro Buttons in the hosted specification, are not supported inside of a Specification Host Control.

Setting Up the Specification Host Control

The Specification Host control requires the following:

  1. A host project where the Specification Host Control is added to a form
  2. A Set Specification Host Control task applied to the host project.
  3. A project that will be hosted within the Specification Host Control.

Specification Host Control Basic Setup

Add the Specification Host Control

The Specification Host Control is added to the host project.

On the form required to display the hosted specification, add the Specification Host Control.

Set the Width and Height properties to be the same as the form that will be displayed for the hosted specification.

Add the Set Specification Host Control Task

Decide when the hosted specification should be initialized:

  • Automatically, when a new specification is started from the host project.
  • Manually, when a macro in the host specification is clicked.

To run the hosted specification automatically:

  1. In the host project, select Specification Flow from the task list.
  2. On the Initial running state click Edit.
  3. In the State Items, select the Enter State.
  4. From the Toolbox select the Set Specification Host Control task and drag it into the Task Sequence for 'Enter State'.
  5. Set the properties of the Set Specification Host Control task as defined below.

To run the hosted specification manually:

  1. In the host project, select Specification Macros from the task list.
  2. Add a new macro, named SetHosted.
  3. From the Toolbox select the Set Specification Host Control task and drag it into the Tasks window.
  4. Connect the Start Node navigation output to the navigation input of the Set Specification Host Control task.
  5. Set the properties of the Set Specification Host Control task as defined below.

The following methods for running a hosted specification are available:

Using the Set Specification Host Control Task to Host Child Specifications

When using the Specification Host control to host child specifications the set up will look like the following:

  1. A host project where the Specification Host Control is added to a form
  2. A Set Specification Host Control task applied to the host project.
  3. A Child Specification List control added to the host project.
  4. A project that will be hosted within the Specification Host Control.

Specification Host Child Setup

When the child specification transitions from the Specification Host control it is added to the child specification list.

A parent - child relationship is maintained between the host and the hosted specification.

Hosting child specifications only supports a single level (parent - child) relationship.

Parent - child - grandchild relationships are not supported.

Set Specification Host Control Task for Hosting Child Specifications

When setting up the Set Specification Host task for hosting child specifications the following methods are available:

  • Host a new Child Specification

    Targets the Specification Host control and a Child Specification List in the host, to create a new child specification from the project specified in the Project Name property.

  • Host an existing Child Specification

    Targets the Specification Host control and a Child Specification List in the host, to run the Transition Name that edits an existing child specification based on the Specification Name or Specification ID property.

Passing Data between the Host and Hosted Child Specification

The Child Specification List control allows data to be passed between parent and child using constants, variables and specification properties.

These are supported when hosting a child specification in addition to the methods for passing data between a host and hosted specification outlined in the following section.

However care must be taken that no conflicts between constants and specification properties occur between the two methods.

Passing Data between the Host and Hosted Specification

When a new or existing child specification is hosted, data can be passed between the host and the hosted specification by using constants and variables applied in the Child Specification List editor launched from the Projects property of the child specification list control.

When a new or existing DriveWorks specification is hosted, data can be passed between the host and the hosted specification by using the following:

  • Input Values property (of the Specification Host Control) is used to pass data from the host to the hosted specification.

    See Passing Data to the Hosted Specification below.

  • Specification Properties (in the hosted specification) are used to pass data from the hosted specification to the host.

    These are returned as an array to the Return value of the specification host control.

    See Passing Data from the Hosted Specification below.

The set up of the Specification Host control for passing data is described as follows:

  1. Specification Host Control applied to the host project.
  2. Set Specification Host Control task applied to the host project.
  3. Input Values property (of the Specification Host Control) configured to pass data to the hosted specification.
  4. Specification Properties in the hosted project configured to pass data back to the host specification.

Specification Host Control Setup

Passing Data to the Hosted Specification

Data can be passed to the hosted specification through the Input Values property on the Specification Host Control (available from the Behavior category for the control properties).

These values will be continuously synchronized between the host specification and the hosted specification.

The data is passed to the Input Values property as a two column table with the headers "Name" and "Value".

Each subsequent row in the table represents the name of a Constant or Control and a value to be passed to the hosted specification.

For example:

The following DriveWorks table (Group Table, Simple Table, Calculation Table) can be referenced by the Input Values property:

NameValue
Height200
ColorBlue

Or the table can be written as an array directly on the Input Values property:

{"Name","Value";"Height","200";"Color","Blue"}

Either method will pass the value "200" into a constant or control named "Height" and the value "Blue" into a constant or control named "Color".

  • Only the name of the constant or control is required (do not use the DWConstant prefix or Return suffix).
  • When a constant and control has the same name, the constant will take priority.

    The control with the same name will not have the value passed into it.

  • Name casing is ignored, for example declaring myconstant will pass the value into MyConstant.
  • A value passed to a control will populate the Return value of the control.

    Ensure the value being passed matches the expected value of the control.

    For example:

    • A value sent to a Combo Box control must be available from the list of items.
    • A value sent to a Spin Button control should fall within the minimum and maximum properties.

Array and Table Data

An array (either written in its raw form or through a table) cannot be passed to a hosted specification directly from the Value column of the Input Values array.

For example, the array:

{"Make","Model","Color";"Volkswagen","Golf","Blue";"Ford","Escort","Red"}

Will not pass into any constant or control in the hosted specification.

To overcome this the array or table data must be converted to one of the following formats:

For example:

  1. Create a Variable named ArrayToCSV
  2. Apply the rule:

    CsvFromTable({"Make","Model","Color";"Volkswagen","Golf","Blue";"Ford","Escort","Red"})

  3. Reference this variable in a two column (Name, Value) Calculation table that is applied to the Input Values property of the specification host control.

Passing Data to the Host Specification

The return value from the Specification Host Control is an array of data that contains the the following information about the hosted specification.

  • Specification Id
  • Specification Name
  • State Name

For example, the following array is returned to the host specification:

{"Specification Id","Specification Name","State Name";40,"Hosted 0040","Specify"}

Additional information can be passed to the Return value of the Specification Host control by creating and applying rules to Specification Properties in the project of the hosted specification.

For example, the following specification properties and rules are applied in the hosted specification:

Specification PropertyRule
LengthLengthReturn
ColorDWConstantColor

The array returned to the return value of the Specification Host control in the host specification will be:

{"Specification Id","Specification Name","State Name","Length","Color";40,"Hosted 0040","Specify",200,"Blue"}

Running Specification Macros

It is possible to trigger a macro to be run in the hosted or host specification, by using the following methods:

These tasks allow interactions between the host and hosted Specifications.

These macros can also be used to pass values between the host and hosted Specifications.

By using the Macro Argument property a value will be passed to the special variable DWCurrentMacroArgument in the hosted or host specification.

Additional Information

The following Tech tips available from my.driveworks.co.uk (login required) show the Specification Host control in action:

  • Child Spec List - See how a Child Specification List can be setup to allow Child Specifications to be created from a Parent Specification.
  • Passing Hosted Data - This Project demonstrates how you can pass data to Specifications hosted using the Specification Host Control.
  • Receiving Hosted Data - This Project demonstrates how to consume data passed by a Specification hosted in a Specification Host Control to the host.
  • Passing Hosted Arrays - This Project demonstrates how you can pass tables, or arrays, of data to Specifications hosted using the Specification Host Control.
  • Receiving Hosted Arrays - This Project demonstrates how to consume tables, or arrays, of data passed by a Specification hosted in a Specification Host Control.


Knowledge Base Article Ref:KB16122101