Drop-down List with Workflow Initialized List via ExecuteQuery

You can use the Drop-down List component to create a Workflow Initialized List of values for a drop-down control. The workflow activity ExecuteQuery enables you to retrieve data from any database for display in a drop-down control.

Our example contains a list of documents retrieved from an Anthology Student database using an ExecuteQuery activity followed by a ForEach<> activity, Assign activities, and an AddToCollection<> activity. Details of the attributes used with each activity are provided below.

Refer to the Drop-down List topic for details about the properties of the Drop-down List control.

Control Property Settings

Drop-Down List properties

Value List is an optional property. Click the Edit button to specify the source of the values to be displayed in the drop-down list.

Workflow Initialized List

Rendered Component

Rendered Component

Workflow Arguments

Argument for Drop-Down List

Use an argument of type Int32 to capture the selections on the form.
Use another argument to capture the full list of selections from the ExecuteQuery.

Workflow Variables

Variables

Workflow Activities

Use an ExecuteQuery activity to initialize the drop-down list. The activity must be placed on a form that precedes the form with the Drop-down List component.

ExecuteQuery

The activity executes the following command:

"select cmdocumentid,originalFileName from cmdocument where systudentid = 51850 order by datelstmod desc"

Note that the systudentid value is hard-coded. Specify an appropriate value/variable for your environment.

The connection string name does not need to be specified when the query is executed on the Anthology Student database. When you query a different database, specify the connection string name.

The out-argument of the query holds the docSet variable, i.e., the data set for the drop-down list.

Place the following activities below the ExecuteQuery activity:

ExecuteQuery

The ForEach<DataRow> activity uses the TypeArgument System.Data.DataRow and the Values property docSet.Tables(0).AsEnumerable

The three Assign activities have the following attributes:

To Value
idList New NameIdObject
idList.Name item("OriginalFileName").ToString
idList.Id CINT(item("CmDocumentID"))

The AddToCollection<NameIdObject> activity uses the following properties:

Property Value
Collection idValues
Item idList
TypeArgument Cmc.Nexus.FormsBuiler.Entities.NameIdObject

The final Assign activity assigns the document Id values to the myDocs argument.

To Value
myDocs idValues.toArray