Managing a Human task from the UI

You can create a Human task using the UI to manage the acquisition of raw materials based on current market prices and user approval.

About this task

Michael, an HCL Universal Orchestrator user, needs to automate the daily process of checking raw material prices and enabling a designated user to approve purchases or sales. Steve, the materials manager, is the authorized user who must review the prices and decide what action to take.
Prerequisites
Email notifications
Micheal has enabled email notifications, as described in Enabling email notifications for Human Tasks.
DAILY_MATERIALS_ACQUIREMENT workflow
Micheal has created a workflow named DAILY_MATERIALS_ACQUIREMENT that runs daily.
RETRIEVE_PRICES task
DAILY_MATERIALS_ACQUIREMENT workflow contains a JSONata task named RETRIEVE_PRICES that is aimed at retrieving prices by calling an API to get the current prices for gold and silver. The message that the RETRIEVE_PRICES task gets from the API call has the following format:
{
 "goldPrice" : 20,
 "silverPrice": 10
}
In the Action section of the RETRIEVE_PRICES, under Queries, Micheal has added the following Key and Value inputs:
  • Key: goldprice; Value: goldPrice
  • Key: silverprice; Value: silverPrice
Gold and silver acquirement tasks
Micheal has already created the four tasks that depend on the decision taken by Steve after having interacted with the Human task:
  • Buy_gold
  • Sell_gold
  • Buy_silver
  • Sell_silver
Such tasks are designed to act upon Steve's decision and buy or sell the specified quantity of gold and silver.
Procedure

Micheal now needs to create a Human task queue and a Human task to make Steve able to interact with the acquirement process. You can find the steps that Michel must perform for such purpose below:

Procedure

  1. Create a queue named /SteveQueue:
    1. In the Graphical Designer page, from the Assets tab, click Add new.
    2. From the drop-down menu, select Human Task Queue.
    3. In Name, type SteveQueue.
    4. In Folder, select a folder from the available items.
    5. In Prefix, type PRX.
    6. Save.
  2. Drag the DAILY_MATERIALS_ACQUIREMENT workflow into the canvas.
  3. Create a Human task template, named TAKE_STEVE_INPUT:
    1. In the Graphical Designer page, from the Assets tab, click Add new.
    2. From the drop-down menu, select Task template.
    3. In the Add new task template panel, expand the Human tasks section, then select Human Task and click Next.
    4. In Name, type TAKE_STEVE_INPUT.
    5. In Workstation, select a workstation.
    6. In the Action section, in Title, type Decide raw materials acquirement.
    7. In Queue, select /SteveQueue.
    8. In Assignee, select Steve.
  4. Edit the TAKE_STEVE_INPUT Human task form to create input fields for Steve to specify the actions to take according to gold and silver daily prices:
    1. In the Action section of the TAKE_STEVE_INPUT task, click the Edit form icon.
    2. Rename the default section display name of the form editor into Gold, then click New section + and add a section named Silver.
    3. From the Basic fields column, drag a Markdown component into the Gold section, enter "Daily gold price" as name and, in the Value field, type: Today's Gold price is: ${jobs.RETRIEVE_PRICES.goldprice}. In this way, Steve can see the daily price of gold as soon as he opens the form; the price is retrieved from the RETRIEVE_PRICES task.
    4. Drag a Select component into the Gold section, enter action_gold as Name, type "Do you want to buy, sell or do nothing?" as Display name, and then set the following 3 options:
      • Display name: Buy - Value: buy.
      • Display name: Sell - Value: sell.
      • Display name: Do nothing - Value: nothing.
    5. Drag an Integer component into the Gold section and type gold_quantity as Name and "Quantity of Gold that you want to buy or sell" as Display name.
    6. Repeat steps C to E for the Silver section, changing names and values accordingly.
    7. Delete the Reject default button and then rename Accept button into Confirm.
    8. Click Save.
  5. Set the output conditions for the TAKE_STEVE_INPUT task:
    1. In the Output conditions section, add the following successful output conditions:
      • Condition name: Buy_gold - Condition Value: $this().action_gold = 'buy'
      • Condition name: Sell_gold - Condition Value: $this().action_gold = 'sell'
      • Condition name: Buy_silver - Condition Value: $this().action_silver = 'buy'
      • Condition name: Sell_silver - Condition Value: $this().action_silver = 'sell'
    2. Click Save.
  6. Click Add at the end of the Add new task template panel.
  7. Drag the TAKE_STEVE_INPUT Human task into the DAILY_MATERIALS_ACQUIREMENT workflow, then set RETRIEVE_PRICES as predecessor of TAKE_STEVE_INPUT using the arrows.
  8. Drag Buy_gold, Sell_gold, Buy_silver and Sell_silver tasks into DAILY_MATERIALS_ACQUIREMENT workflow.
  9. Set TAKE_STEVE_INPUT as predecessor of Buy_gold and select Buy_gold from the output conditions drop-down menu. Then, repeat this step for all the other tasks:
    • On Sell_gold task, select the Sell_gold output condition.
    • On Buy_silver task, select the Buy_silver output condition.
    • On Sell_silver task, select the Sell_silver output condition.
  10. Deploy the workspace.

Results

When the DAILY_MATERIALS_ACQUIREMENT workflow runs, the RETRIEVE_PRICES task runs and fetches the daily prices for gold and silver. At this point, the TAKE_STEVE_INPUT task starts and Steve receives an email with a link to the assigned task. When Steve opens the Human Task page on the UI, he sees the raw materials acquirement task waiting in /SteveQueue. The form displays the current gold and silver prices, and Steve fills out the form, selecting buy for gold and specifying the quantity; he then selects Do nothing for silver, and confirms the form to complete the task.
At this point, the TAKE_STEVE_INPUT task status changes to Successful, and the DAILY_MATERIALS_ACQUIREMENT workflow evaluates the output conditions for the subsequent tasks. Consequently:
  • The Buy_gold task runs to perform the purchase that Steve approved.
    Note: To establish the quantity of gold to buy, the Buy_gold uses the gold_quantity output property that was provided in the form of the TAKE_STEVE_INPUT Human task: ${jobs.TAKE_STEVE_INPUT.gold_quantity}
  • Neither Buy_silver or Sell_silver tasks start because their conditions were not met.