6. Create the Expense Claim Details SmartObject
In this step, you will create the second SmartBox SmartObject. This SmartObject stores the expense claim line items. Nintex K2 creates a separate record for each line item row. These are the "child" records to the header "parent" record. You will associate, or bind, the header and details SmartObjects together via a common ID property.
- Add another SmartObject from the SmartObjects category. Name it Expense Claim Details, then confirm SmartBox as the Type. Create the SmartObject.
- From the Designer explorer, right -click the SmartObjects category and select New SmartObject.
- On the GENERAL settings page, name the new SmartObject
Expense Claim Details
then make sure the Type is set to SmartBox. Click CREATE.
- From the Designer explorer, right -click the SmartObjects category and select New SmartObject.
-
Using the same process as the header SmartObject, add the following properties:
Property Type Notes Expense Claim ID Number
(Required)This property stores the ID of the associated Expense Claim Header SmartObject. This is the common property that binds the header (parent) record to the (details) child records. Category ID Number This property stores the category ID for the expense item category. The categories are provided by the Azure SQL database you configured in a previous step. Payee Text This is who the expense was paid to. Date Date This is the date of the expense. Description Memo This property is a description for the expense line item. Amount Decimal The source amount for the expense claim (potentially in another currency). Currency Code Text The currency code for the expense amount. USD Amount Decimal The USD equivalent amount. This value is automatically calculated by the Calculate USD Amount method. Receipt Image Use this property to attache a receipt for your expense. - Click Add to add the following properties and types to the SmartObject. Click OK to continue.
Property Type Notes Expense Claim ID Number
(Required)This property stores the ID of the associated Expense Claim Header SmartObject. This is the common property that binds the header (parent) record to the (details) child records. Category ID Number This property stores the category ID for the expense item category. The categories are provided by the SQL database you configured in a previous step. Payee Text This is who the expense was paid to. Date Date This is the date of the expense. Description Memo This property is a description for the expense line item. Amount Decimal The source amount for the expense claim (potentially in another currency). Currency Code Text The currency code for the expense amount. USD Amount Decimal The USD equivalent amount. This value is automatically calculated by the Calculate USD Amount method. Receipt Image Use this property to attache a receipt for your expense.
- Click Add to add the following properties and types to the SmartObject. Click OK to continue.
-
Next, you will associate this SmartObject with both the header (Expense Claim Header) and the categories (Expense Claim Categories) SmartObjects. This creates a bond between the SmartObjects.
You will use the Expense Claim Categories SmartObject for the Category ID drop-down list. The list retrieves its values from the SQL database.
The Expense Claim Header SmartObject becomes the parent data source, while the details SmartObject becomes the child data source.Associated SmartObject Association Property Mappings Expense Claim Header Each Expense Claim Details has a single Expense Claim Header and an Expense Claim Header can have many Expense Claim Details. Expense Claim Details.Expense Claim ID = Expense Claim Header.ID Expense Claim Categories Each Expense Claim Details has a single Expense Claim Categories and an Expense Claim Categories can have many Expense Claim Details. Expense Claim Details. Category ID = Expense Claim Categories.CategoryId - First, you will associate the Expense Claim Header SmartObject with the Expense Claim Details SmartObject. Click the ASSOCIATIONS tab in the toolbar. Click the Add button.
SmartObject associations create a relationship between two SmartObject data sources. Like a SQL JOIN statement, you associate SmartObjects by mapping common properties, for example, an ID property. In this step, the parent is the Expense Claim Header SmartObject and the child is the Expense Claim Details SmartObject. You will have one parent record and one or more child records associated with the parent.
- On the Add Association screen, navigate to the Expense Claim Header SmartObject. Click NEXT.
- Configure the association so that each Expense Claim Details has a single Expense Claim Header and an Expense Claim Header can have many Expense Claim Details. Select the Use Existing Property radio button and click NEXT.
- Now you need to tell the system which property should be the common association between the two SmartObjects. Generally, this is an ID property of some kind. Select the Expense Claim ID property, then click Assign. You will map the Expense Claim ID property (from the Expense Claim Details SmartObject) to the ID property (from the Expense Claim Header SmartObject).
- In the dialog box, select ID from the drop-down list and click OK.
- The Add Association screen should look like the image below. Click FINISH to complete the association wizard. (Finish is the equivalent of save.)
- Next, you will add another association to associate the expense claim with an expense category. This allows the smartform to auto-generate a drop-down menu for the expense category when users enter the individual items for the expense claim.
Click the Add button. On the Add Association screen, select the Expense Claim Categories SmartObject, then click NEXT. - Configure the association so that each Expense Claim Details has a single Expense Claim Categories and an Expense Claim Categories can have many Expense Claim Details SmartObjects. Select the Use Existing Property radio button, then click NEXT. Once again, each line item record will have a single category, while each category may have many line items.
- On the Add Association screen, select the Category ID property, then click Assign. You will associate the Category ID property (which will become the category drop-down list control on your form) with the SQL SmartObject. When your form loads, the category control is populated with the values it finds from the Expense Claim Categories SmartObject.
- In the pop-up dialog box, select the ExpenseCategoryId property, then click OK.
- Click FINISH to complete the association wizard.
- First, you will associate the Expense Claim Header SmartObject with the Expense Claim Details SmartObject. Click the ASSOCIATIONS tab in the toolbar. Click the Add button.
- Finish the SmartObject wizard.
- Click FINISH to complete the SmartObject wizard.
- Click FINISH to complete the SmartObject wizard.
Review
In this step, you created the final data source for this application, the Expense Claim Details SmartObject. This SmartBox SmartObject stores the line items entered for each expense claim. You associated this SmartObject with the Expense Claim Header SmartObject, which creates a bond between the two SmartObjects, forming a parent-child record model. You also associated this SmartObject with the Expense Claim Categories SmartObject; this association allows the automatic population of the categories drop-down list with values retrieved from the SQL database. Now that you have the data sources defined, you are ready to begin building the views and form. In the next step, you will build the Expense Claim Header view.