Exercise: Add the Custom Parameter Set Table for the Business Process
Individual parameters are organized into a parameter set. A business process can be designed to accept zero, one, or several parameters. The end user can define multiple parameter sets for a given business process.
Before a business process starts, the end user creates one or several parameter sets, selects a parameter set, and starts the business process instance. With the parameter set for guidance, the business process instance processes the data.
When the business process processing starts, the parameter set values are retrieved and the processing on the data begins in earnest. The parameter set values are stored within a custom database table. For details, see Business Process Parameter Set Table (USR_INVENTORYPROCESS).
Figure: Parameter Sets
Step 1 - Prerequisites.
-
Ensure Blackbaud CRM is open to the correct environment. If you are participating in instructor led training, your instructor will direct you to the correct training environment that fulfills these prerequisites.
-
The examples in this document extend the capabilities of the Food Bank functional area, which was built to illustrate the customization and configuration capabilities of an Infinity-based application. Ensure the features that represent the food bank sub application are loaded into the database that you use for this training. If you work out of your own training software development environment, ensure the features that represent the food bank sub application are loaded into the Infinity Catalog System/database that you use for this training.
The FoodBank.Package.xml file within the project lists the required specs that should be loaded prior to starting the exercises outlined within this document. The features that make up the food bank sub application can be found within the Blackbaud.CustomFx.FoodBank.Catalog Visual Studio project within the source code.
-
Ensure you have several food bank organization records of varying food bank types in the database. At least one food bank should be associated with a food bank type equal to "Ecumenical" or something similar. See the "Add Food Bank" task within the Food Bank functional area to add a new food bank to the system, if needed.
-
Each food bank should contain multiple food bank transactions of type "Receive" and "Distribute."
Step 2 - Create an InventoryProcess folder within the catalog project.
-
Open your Blackbaud.CustomFx.FoodBank.Catalog project.
-
Within your Visual Studio Blackbaud.CustomFx.FoodBank.Catalog project, ensure there is a folder named InventoryProcess. We will put our Business Process Specs in this folder. If the folder does not exist, add the folder by right-clicking the Visual Basic project and select Add\new folder from the popup menu.
Figure: Add the InventoryProcess folder within the catalog Visual Basic project if it does not already exist
Step 3 - Add a TableSpec to the InventoryProcess folder.
-
Right-click the InventoryProcess folder and add a new item.
-
Select Blackbaud AppFx Catalog as the category and Table Spec as the item template.
-
Name the spec file: InventoryProcess.Table.xml
Step 4 - Identify the table.
At the top of the spec, provide the following values in the TableSpec element to identify the table in the system.
The Name attribute is the friendly name for the table within the system and defines the record type value that the end user see within the user interface. The Tablename attribute defines the database table name. The Tablename attribute value corresponds with the Business Process Spec's ParameterTableName attribute value.
<TableSpec xmlns="bb_appfx_table" xmlns:common="bb_appfx_commontypes" ID="e7d7fadd-b188-4bda-90b0-31b915a66f06" Name="Inventory Process Parameter" Description="Table to store business process parameters for the inventory business process." Author="Technical Training" Tablename="USR_INVENTORYPROCESS">
Step 5 - Define the fields within the table to support the parameters.
An end user relies upon an Add Data Form and Edit Data Form to save parameter data into the custom database table. Add four fields into the Table Spec, one for each parameter. The parameter set this TableSpec supports includes:
Note: When defining a parameter set table, a NAME column or some other column should be used to represent the label for the business process parameter set. This table column corresponds with the BusinessProcessSpec element's ParameterLabelField attribute which is used to identify the name of the field in the parameter table which represents the label for the parameter set. If the ParameterLabelField attribute for the BusinessProcessSpec element is not specified, NAME is used as the default. If the default is used and NAME does not exist on the parameter table, loadspec will throw an error. We recommend you explicitly identify the ParameterLabelField in your business process specs.
-
A NAME text field is used to label the parameter set.
-
A DESCRIPTION text field to describe the business process instance.
-
The IDSETREGISTERID foreign key field points to a system table named IDSETREGISTER. Each row in the IDSETREGISTER table corresponds to a view or table-valued function that returns a list of Primary Key ID values of a particular record type (database table), such as Constituent or Revenue. For more information, see a Using a Selection as a Parameter to Restrict the Row Set.
-
A QueryViewSpec can be used to drive the columns of data also known as the Output Format, which is created as a business process. The QUERYVIEWID foreign key field is used to reference a query view to dictate the output format. For more information, see Using a QueryViewSpec as a Parameter for Output Formatting.
While this exercise highlights the best practice of using a QueryViewSpec to help format the output and a selection to help restrict the row set of a business process, keep in mind you are free to develop whatever parameters you see fit to create your custom solution. You are also free to create any type of output your requirements dictate.
To define the columns for the USR_INVENTORYPROCESS table, add the Fields XML element and its child elements below the TableSpec XML element.
<TableSpec xmlns="bb_appfx_table" xmlns:common="bb_appfx_commontypes" ID="e7d7fadd-b188-4bda-90b0-31b915a66f06" Name="Inventory Process Parameter" Description="Table to store business process parameters for the inventory business process." Author="Technical Training" Tablename="USR_INVENTORYPROCESS"> <!-- define fields on the table --> <Fields> <TextField Name="NAME" Length="100" Required="true" IsUnique="true" Description="The name of the parameter set"/> <TextField Name="DESCRIPTION" Length="255" Description="Details describing this parameter set"/> <ForeignKeyField Name="IDSETREGISTERID" ForeignTable="IDSETREGISTER" Cardinality="ManyToOne" Required="true" OnDelete="CascadeDelete"/> <ForeignKeyField Name="QUERYVIEWID" Cardinality="ManyToOne" ForeignTable="QUERYVIEWCATALOG" Required="true"/> </Fields>
Step 6 - Add a trigger to delete related records within BUSINESSPROCESSINSTANCE.
The BUSINESSPROCESSINSTANCE supports the securing of a parameter set for a business process to a particular site and/or selected security roles. Therefore when a row is delete from our custom parameter set table, we need to delete the relate rows within the BUSINESSPROCESSINSTANCE table.
-
Below the Fields XML element, add the following Triggers XML element to define a trigger which deletes related records within the BUSINESSPROCESSINSTANCE table.
-
Place the ending TableSpec XML element below the Triggers XML element to complete the spec.
<TableSpec xmlns="bb_appfx_table" xmlns:common="bb_appfx_commontypes" ID="e7d7fadd-b188-4bda-90b0-31b915a66f06" Name="Inventory Process Parameter" Description="Table to store business process parameters for the inventory business process." Author="Technical Training" Tablename="USR_INVENTORYPROCESS"> <!-- define fields on the table --> <Fields> <TextField Name="NAME" Length="100" Required="true" IsUnique="true" Description="The name of the parameter set"/> <TextField Name="DESCRIPTION" Length="255" Description="Details describing this parameter set"/> <ForeignKeyField Name="IDSETREGISTERID" ForeignTable="IDSETREGISTER" Cardinality="ManyToOne" Required="true" OnDelete="CascadeDelete"/> <ForeignKeyField Name="QUERYVIEWID" Cardinality="ManyToOne" ForeignTable="QUERYVIEWCATALOG" Required="true"/> </Fields> <Triggers> <Trigger Name="TR_USR_INVENTORYPROCESS_DELETE_BUSINESSPROCESSINSTANCE" Enabled="true" Description="Used to delete the common business process records associated with this record."> <CreateTriggerSQL> <![CDATA[create trigger TR_USR_INVENTORYPROCESS_DELETE_BUSINESSPROCESSINSTANCE on dbo.USR_INVENTORYPROCESS after delete not for replication as begin delete from dbo.BUSINESSPROCESSINSTANCE where BUSINESSPROCESSPARAMETERSETID in (select ID from deleted) and BUSINESSPROCESSCATALOGID = 'a28d4f17-53fe-48d9-85bc-37e12884dc00'; end ] ]> </CreateTriggerSQL> </Trigger> </Triggers> </TableSpec>
-
Save and load the TableSpec to create the USR_INVENTORYPROCESS parameter set table and associated trigger within the database.