24. Edit the Edit Expense Claim Form

Now that you have deployed your final workflow version, you will return to editing rules. In this step, you will add actions that update the records with any changes made by the originator during the rework task. You will also create new details records the originator adds and delete any details records the originator removes.

Update existing header record

  1. Edit the Edit Expense Claim form. Edit the When the Workflow View is being submitted rule for the Workflow Task state.
    1. Check out, then edit the Edit Expense Claim form. Click the RULES tab. Edit the When the Workflow View is being submitted rule for the Workflow Task state.
      Edit Workflow Rule
  2. Add an action to Execute a View method and configure the action to call the Update List Item method of the Edit Expense Claim view. You are updating the existing header record with any changes to the header view the originator made.
    1. Add an action to Execute a View method and configure the action to call the Update List Item method of the Edit Expense Claim view. Click the configure link. You are updating the header record for this claim.
  3. Input Mappings: Map the Edit Expense Claim form > Parameters > ID to the ID input property. Here, you are mapping the ID of the current record (Parameters > ID) as the ID for the record to update (Input Properties).
    1. First, you need to tell K2 which record to update. You are mapping the ID of the "current" expense claim record as the record to update. This is the record K2 associates with the workflow instance.
      On the Input Mappings screen, expand the Edit Expense Claim form > Parameters node in the Context Browser, then drag the ID parameter into the ID input property.
  4. Map the following controls to the input properties: Title Text Box, Requester Text Box, Approver Text Box, Requester Comments Text Area, Total Amount Data Label. Now, you mapping the form fields to their respective SmartObject properties.
    1. Next, you will map form fields to the Expense Claim SmartObject.
      Expand the Controls node, then drag the following controls into the input properties: Title Text Box, Requester Text Box, Approver Text Box, Request Comments Text Area, Total Amount Data Label. You only need to update the values that the originator can change, so you will not map all properties.
    2. Click FINISH to complete the mappings setup. You don’t need to save the returned ID from the header like you did for the New Expense Claim form because the child records are already mapped to their parent record ID. Next, you will add the actions for the Expense Claim Items view. These are the actions for adding, updating, or deleting list items (or child records).
  5. Add new expense claim items

  6. Execute a View method for items that are in a specific state. Use the Create method of the Expense Claim Line Items Edit List view for all the items that have been Added.
    1. Add an action to Execute a View method for items that are in a specific state, then configure the action to execute the Create method of the Expense Claim Line Items Edit List view for all the items that have been Added. Click the configure link. Here, you are creating a new child record in the SmartObject for each new item the originator added.
  7. Map the Edit Expense Claim > Parameters > ID to the Expense Claim ID input property.
    1. On the Input Mappings screen, expand the Edit Expense Claim node in the Context Browser, then expand the Parameters node and drag the ID parameter over to the Expense Claim ID input property. Now, you are binding the new child record(s) with the parent record via the ID.
  8. Map the Expense Claim Line Items Edit List > Expense Claim Line Item SmartObject properties to the input mappings.
    1. Now expand the Expense Claim Line Items Edit List > Expense Claim Line Item SmartObject and drag the properties for the SmartObject into the input mappings. When you are mapping properties for an editable list (that loops through each row/record), you must use the properties from the associated SmartObject and not the controls.
    2. Click NEXT then FINISH to complete the action configuration.
  9. Update existing expense claim items

  10. Execute a View method for items that are in a specific state. Use the Save method of the Expense Claim Line Items Edit List view for all the items that have been Changed.
    1. Add an action to Execute a View method for items that are in a specific state and configure the action to execute the Save method of the Expense Claim Line Items Edit List view for all the items that have been Changed. (In K2, save is the equivalent of update.)Here, you are updating existing child records with any changes made by the originator. Click the configure link.
  11. Map the properties from the Expense Claim Line Item SmartObject to the Input Properties.
    1. For the Input Mappings, drag all the properties from the Expense Claim Line Item SmartObject over to the Input Properties. You do not use the ID form parameter for the Expense Claim ID because the Expense Claim header ID already exists for changed items.
    2. Click FINISH to complete the mapping configuration.
  12. Delete expense claim items

  13. Execute a view method for items that are in a specific state. Use the Delete method of the Expense Claim Line Items Edit List view for all the items that have been Removed.
    1. Add an action to Execute a view method for items that are in a specific state, and configure the action to execute the Delete method of the Expense Claim Line Items Edit List view for all the items that have been Removed. Click the configure link.
  14. Map the Expense Claim Line Item > ID to the input properties.
    1. The only input mapping needed is the ID of the Expense Claim Line Item SmartObject. Here, you are removing any child records the originator deleted from the form.
    2. Click FINISH to complete the input mappings configuration.
  15. Add confirmation message when expense claim is resubmitted.

  16. Add an action to show a message after the claim is resubmitted using content of your choice.
    1. Add an action to show a message and configure it as shown in the screen shots below. Click OK to continue.

  17. Close the browser window after the resubmit.

  18. Add an action to Close the browser window.
    1. Add an action to close the browser window. Your actions should look like the image below.
  19. Change the methods (create, save, delete) to run as a batch. Finish the form, then check in any views and forms still checked out.
    1. Change the execution block to run as a batch. This is so the add, edit and update actions run as a block before K2 moves on to the next rule.
      In the Rule Actions section, select the then on Edit Expense Claim view, execute the Update List Item method action. Click then and change it to also.
    2. Repeat the step above for the Create, Save and Delete actions, so that they run in a batch. The four actions now run in a single batch action.
    3. Click OK to complete the Rule Designer, then click FINISH to complete the Form Designer and return to the K2 Application elements page.
    4. Check in any views or forms that you have checked out. You have completed the required changes for the Edit Expense Claim form. If time permits you can test the Edit Expense Claim form as described below, otherwise continue on to the next step.
  20. Test the rule change

  21. From the K2 Application elements page, run the Edit Expense Claim form with a parameter. Enter 1 for the ID. Confirm you have both parent and child records returned.
    1. On the K2 Application elements page, right-click the Edit Expense Claim form and select Run with Parameters. You will add the Expense Claim list item ID for an item added earlier. Because you are not opening the parent form first, K2 doesn't know which parent or child records to retrieve so you must provide the parent ID for testing.
    2. On the parameters screen, provide a value for the ID parameter, then click Run. The ID value "1" is most likely the first test item added to the Expense Claim list, but you can try sequential numbers if the edit form does not show any data.
    3. The form should populate with the parent record and correct child records. There is not a submit button yet, so you cannot change the records at this point. Close the Edit Expense Claim browser window.

      Troubleshooting

      If things did not work as expected, the most likely cause is that you did not use the parameter ID in the rule actions. Review the steps for mapping the Expense Claim ID.

Review

In this step, you worked with rules to add, update, or delete any changes the originator made during the rework task. You learned how to work with parent records and child records. First, you updated the parent record, then you configured actions to either add, update, or delete child records. You configured the actions to ran as a batch, which simply means K2 completes the processing of this batch group before it moves on to the next rule, condition, or action. Next, you will edit the display form and configure rules to add any comments the approver or finance processor entered.

Next Step: 25. Edit the Display Expense Claim Form
Expense Claim Application