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.

  1. Add another SmartObject from the SmartObjects category. Name it Expense Claim Details, then confirm SmartBox as the Type. Create the SmartObject.
    1. From the Designer explorer, right -click the SmartObjects category and select New SmartObject.
    2. On the GENERAL settings page, name the new SmartObject
      Expense Claim Details
      then make sure the Type is set to SmartBox. Click CREATE.
      SmartObject General Settings
  2. Using the same process as the header SmartObject, add the following properties:
    PropertyTypeNotes
    Expense Claim IDNumber
    (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 IDNumberThis 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.
    PayeeTextThis is who the expense was paid to.
    DateDateThis is the date of the expense.
    DescriptionMemoThis property is a description for the expense line item.
    AmountDecimalThe source amount for the expense claim (potentially in another currency).
    Currency CodeTextThe currency code for the expense amount.
    USD AmountDecimalThe USD equivalent amount. This value is automatically calculated by the Calculate USD Amount method.
    ReceiptImageUse this property to attache a receipt for your expense.
    1. Click Add to add the following properties and types to the SmartObject. Click OK to continue.
      PropertyTypeNotes
      Expense Claim IDNumber
      (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 IDNumberThis property stores the category ID for the expense item category. The categories are provided by the SQL database you configured in a previous step.
      PayeeTextThis is who the expense was paid to.
      DateDateThis is the date of the expense.
      DescriptionMemoThis property is a description for the expense line item.
      AmountDecimalThe source amount for the expense claim (potentially in another currency).
      Currency CodeTextThe currency code for the expense amount.
      USD AmountDecimalThe USD equivalent amount. This value is automatically calculated by the Calculate USD Amount method.
      ReceiptImageUse this property to attache a receipt for your expense.
      Add Details SmartObject Properties
  3. 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 SmartObjectAssociationProperty Mappings
    Expense Claim HeaderEach 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 CategoriesEach 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
    1. 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.
      Add New Association
    2. On the Add Association screen, navigate to the Expense Claim Header SmartObject. Click NEXT.
      Add Association Screen
    3. 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.
      SmartObject Associations
    4. 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).
      Add Association - Bind ID
    5. In the dialog box, select ID from the drop-down list and click OK.
      Assign Property Screen
    6. The Add Association screen should look like the image below. Click FINISH to complete the association wizard. (Finish is the equivalent of save.)
      Completed SmartObject Association
    7. 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.
      Assign Association Screen
    8. 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.
      Define Association Screen
    9. 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.
    10. In the pop-up dialog box, select the ExpenseCategoryId property, then click OK.
      Assign Property Screen
    11. Click FINISH to complete the association wizard.
  4. Finish the SmartObject wizard.
    1. Click FINISH to complete the SmartObject wizard.
      Finish a SmartObject
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.

Next Step: 7. Create the Expense Claim Header (Item) View