17. Add a Task step to Approve, Reject or Query the Expense Claim

In this step, you will add and configure the first Task step, used to approve or reject the claim. This step has three action options: Approved, Rejected, and Query. You will update the status column for each of the action outcomes, then send an email to the originator for the Approved and Rejected outcomes. Overall, you will configure the workflow as follows:

  1. From the Toolbox > Basic menu, add a Task step to the design canvas below the Set Status Submitted step. Connect the two steps. Configure the Task step as follows:
    • Instructions: Please review and approve, reject, or query the new expense claim.
    • Actions: Approved, Rejected, Query
    • Form: SmartForm > Display Expense Claim
      • References: Keep default settings
      • Open Task: Help me configure it
      • Workflow View: Create a new State: Workflow Task
      • Open Task Rule Action: Keep default settings
      • After submit: Keep default settings
      • Summary: Save and Finish
    • Recipients: Select Browse, then search for the Expense Claim Approvers group.
    • Email Alert: Customize the notification to include Context Browser references in the SUBJECT line and BODY.
    • Adding Context Browser References

      Adding Context Browser References

    • Properties: Rename the step: Approve Expense Claim
    1. Begin by adding a Task step to the design canvas. This is a user task that assigns the approval decision to a person or group. These are the task recipients. The recipients can decide whether to approve, reject, or query (send the workflow back for rework) the claim.
      Click the Toolbox icon to return to its main menu.
      Toolbox Icon
    2. Expand the Basic node, then drag a Task step onto the design canvas, below the Set Status Submitted step.Adding a Task Step to the Canvas
    3. Connect the two steps. Hover over the bottom border of the Set Status Submitted step to expose the outcome handles. Click and drag the handle from the Set Status Submitted step to the Task step, connecting the two. Click anywhere on the design canvas to set the line.
      Connecting Steps
    4. Select the Task step, then expand the Configuration Panel. Click the Task tab, if it is not already active.
      Configuring the Task Step
    5. For the INSTRUCTIONS, enter
      Please review and approve, reject, or query the new expense claim.
    6. For the ACTIONS, click the Add (+) icon. For the first action, enter
      Approved
      then add a second action,
      Rejected
      then add a third action,
      Query
      Entering Actions for a Task
    7. Click the Form tab. For the FORM TYPE, select SmartForm. For the FORM, browse and select the Display Expense Claims Form. You will use the display form because you do not want the recipients to make any changes to the form entries. Click OK to launch the wizard.
      Your explorer structure may be different than the image below, depending on how you configured SharePoint (such as subsite, list name).
      Browsing to Select a SmartForm
    8. The Open Task on a Form wizard launches.

    9. There are no changes to the REFERENCES screen, so click NEXT.
      References Screen for the Task Form Wizard
    10. On the OPEN TASK screen, select Help me configure it, then click NEXT.
      Open Task Screen for the Task Form Wizard
    11. On the WORKFLOW VIEW screen, confirm Create a new State is the default, and the state name is Workflow Task. States represent the form's configuration and behavior for a specific use. You can have many states for one form. This allows you to use the same form, but configure it to look and behave differently depending on the use. In this case, you are creating the state that represents the form's behavior for this approval Task step. Click NEXT.
      Create a New State
    12. On the OPEN TASK RULE ACTION screen, keep the default settings and click NEXT.
      Setting Form Rules to Start a Workflow
    13. There are no changes to the AFTER SUBMIT ACTION screen, click NEXT.
    14. The final screen is the summary. Review the settings, then click SAVE AND FINISH. When you see the Success check, click OK to exit the wizard.
      Summary Screen for the Task Form Wizard
    15. Next, you will configure the recipient, or person who is responsible for completing this task. You are assigning the task to the Expense Claim Approvers group that you previously created in SharePoint.
      Click the Recipients tab. By default, the recipient is Originator. You want to change this to the SharePoint group. Click anywhere in the Originator box to expose the drop-down menu, then select Browse.
    16. On the Select User page, enter
      approvers
      into the search box. K2 resolves search results as you type. Select Expense Claim Approvers when you see it returned. Select the group, then click OK.

    17. Click the Email Alert tab. You will personalize the task notification email the recipients receive. You can use references from the Context Browser in both the subject line and the message body. At runtime, K2 replaces the references with "live" data, specific to the workflow instance.
      CHECK the box to Customize Notification. Notice that the BODY containing the default email template is now editable.
      Editing the Task Notification Email
    18. The Context Browser provides access to data about the current user and process, as well as functions and SmartObject data. You can use variables dragged from the Context Browser throughout the configuration of workflow steps. At runtime, K2 replaces the variables with "live" data. There are four tabs:
      • Fields: This section contains references to SharePoint lists, SmartForms, and SmartObjects. You can also create variables to hold and use data within the workflow itself, such as to store record IDs.
      • Functions: This section contains tools for transforming data. Some examples include performing calculations, formatting text, and working with date and time values.
      • SmartObjects: This section contains system and custom SmartObject references.
      • Workflow: This section contains process variables. Examples include the originator's name, email, manager, and folio.
    19. To personalize the subject line, you will add a reference from the Context Browser. Begin by entering the following into the Subject line:
      New Expense Claim:
    20. Expand the Context Browser. Expand the REFERENCES node. Notice the Expense Claim SmartObjects. Expand the Expense Claim SmartObject , then drag the Title property to the end of the Subject line.
      Using a SmartObject Reference in an Email Subject Line
    21. You will include some information about the claim in the message body. This allows the approver to make a decision without having to open the form or the list item. Click in the BODY section of the email after the first line and add some descriptive text such as:
      A new expense claim titled [TITLE] has been submitted for the US dollar amount: [TOTAL AMOUNT]
      Customizing an Email Message
    22. From the Context Browser, drag the Title and Total Amount properties into the sentence, replacing the bracketed text.
      Using SmartObject References in an Email Message
    23. Recipients can action a task in one of three ways:
      • reply to the email itself with one of the actions as the message body
      • open the form and action the task from the form
      • access the K2 Worklist web part in SharePoint and choose an action from the context menu
      By providing some basic information in the email, the recipient can decide which of the methods above is best.
    24. The final configuration is to rename this step. Click the Properties tab. Rename the step to
      Approve Expense Claim
      then collapse the Configuration Panel.
      Changing the Task Step Name and Label
  2. Add a Decision step and connect it to the Approve Expense Claim step.
    1. The Decision step generates the outcomes for the Approve Expense Claim step. You can configure conditional rules for outcomes as well in the Decision step. In this case, you just want to generate the lines.
      From the Toolbox > Logic node, drag a Decision step below the Approve Expense Claim step. Connect the two steps. Notice that the actions configured in the Task step are now represented as outcomes from the Decision step.
      The Site Request Workflow Partial Complete
  3. Add three Update List Item steps (one for each outcome). Update the status column to reflect the approver decisions. Add the Approval Date to the approved properties. Add the Now() function for the Approval Date value HINT: You can copy and paste the existing Set Status Submitted step if you like. Change the status values to reflect the outcomes. Add the Approval Date to the approved properties. Add the Now() function for the Approval Date value.
    Outcome/PropertyStatus/ValueApproved Date
    ApprovedApproved 
    Approval Date (as part of the Approve outcome properties)Now()Use the Now() Date and Time Inline Function to set the approval date to the current date.
    RejectedRejected(not applicable)
    QueryQuery(not applicable)
    1. Now that the Approve Expense Claim task is complete, you will add steps for each of the outcomes. You will update the status for each outcome, then send email notices for the approved and rejected outcomes. You will copy and paste the existing Set Status Submitted step, then reconfigure it. Reusing steps saves time and helps maintain consistency.
      Select the Set Status Submitted step, then click Home > Copy.
      Copy Existing Step
    2. Click Home > Paste. K2 duplicates the step. Drag the duplicated step to the left of the Approved outcome, then connect the outcome to the step.
      Duplicated Step
    3. Select the duplicated Set Status Submitted step, then expand the Configuration Panel.
    4. Click the Update List Item tab so that it is active. Notice the Pick List Item value is already set. Under the PROPERTIES heading, notice the Status is already set. Change the Status value to
      Approved
      then click the Add (+) icon. CHECK the box for the Approval Date property. For this value, you will add a reference to today's date.
      Setting the Status Property for Approved
    5. Expand the Context Browser. Click the Functions tab. Expand the DATE AND TIME node. Drag the Now function into the Approval Date text box.
      Adding the Now Function
    6. Click the Properties tab. Change the step name to
      Set Status Approved
      then collapse the Configuration Panel.
      Setting a Step Label Name
    7. Repeat the steps above and copy, then paste, the Set Status Submitted step for both the Rejected and Query outcomes. (Just update the status, you don't need to update any date properties for these steps.) Be sure to change the step names as well.
    8. Your workflow should look like the image below at this point.
      Expense Claim Workflow Partial One

  4. Add Send Email steps to the Approved and Rejected outcomes to notify the originator that the item was approved or rejected. Use the image below for reference or create your own content if you prefer.
    Approved E-mail:

    Your workflow should look like the image below at this point.

    1. The final configuration for the Approve Expense Claim step is to add Send Email steps for the approved and rejected outcomes. The emails inform the originator of the approver's decision. From the Toolbox > Basic node, drag a Send Email step below the Set Status Approved step. Connect the steps.
      If you are running out of design canvas space, click anywhere on the design canvas, then drag your mouse. This moves the entire workflow structure so that you have more room.
      Adding a Send Email Step to the Canvas
    2. Select the Send Email step, then expand the Configuration Panel. Confirm the TO value is Originator. For the SUBJECT line, enter
      Your expense claim titled: [TITLE]
      then drag the Context Browser > REFERENCES > Expense Claim SmartObject > Title property to the end of the subject line. (You may need to click the Fields tab to return to the SmartObject references.)
      Adding Context Browser Content to a Subject Line
    3. Enter any content you like for the message BODY. Use references from the Context Browser to add additional customization.
      Adding Context Browser Content to an Email Body
    4. Click the Properties tab. Change the name of the step to
      Send Email Approved
      then collapse the Configuration Panel.
      Setting a Send Email Step Label
    5. Copy and paste the Send Email Approved step, then connect it to the Set Status Rejected step. Update the subject line and message body to reflect the rejected decision. Change the step name to
      Send Email Rejected.
    6. Your workflow should look like the image below.
      Expense Claim Workflow Partial Two

Review

In this step, you completed the approval outcome steps. You added a Task step, then configured it to use the Display Expense Claim form so that the approvers cannot change any of the originator's entries. You learned how to copy and paste existing steps. This saves time and maintains consistency across your step configuration. In the next step, you will deploy the partially completed workflow. You will configure the workflow start rules on the New Expense Claim form before continuing the workflow build. You must deploy the workflow first, so that K2 "sees" the workflow in the form rules.

Next Step: 18. Deploy the Partial Build Expense Claim Workflow
Expense Claim Application