Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel

Table of Contents
maxLevel3

Introduction

On this page, we will enhance the ue-task Extension to support Output Only fields.  These are fields that are designed to be updated by an Extension instance running on an agent system.  They can be used for any purpose but, a typical use case is to reflect state changes that occur in the Extension instance.  That is what we will simulate here.

...

  1. Add Output Only fields to the "UE Task" Universal Template.
  2. Modify extension.py to populate Output Only fields.
  3. Execute ue-task-test task and review the Output Only field updates

Step 1 - Output Only fields to the "UE Task" Universal Template

Go back to the "UE Task" Universal Template form.  

...

Fields step_1 and step_2 will be used to reflect the progression of work in the task instance as it works its way through them.

Step 2 - Add support for updating Output Only fields in extension.py

Open file ~/dev/extensions/sample-task/src/extension.py in your editor of choice.

...

Line 2We added an import for the time module to gain access to the sleep function which we will use to force controlled delays between Output Only field updates.
Line 7We added an import for the ui module to access the update_output_fields() method
Line 70We initialize variable sleep_value.  This variable will be used to control the sleep delays.
Line 73We create a new dictionary to hold output fields to be sent back to the Controller.
Lines 74 to 76We format a task_action string using the primary_choice_field and secondary_choice_field values passed down from the Controller.
Line 77We assign the formatted task_action string value to the out_fields dictionary using key "task_action" to associate it with the "task_action" Output Only field in associated task instance in the Controller.
Line 78This calls the update_output_fields() method from the ui module.  This will send a message to the Controller and update the value of the specified fields in the associated task instance (in this case just "task_action").
Lines 80 to 94This follows the same basic basic procedure to update Output Only fields step_1 and step_2.  A sleep delay is introduced between each output field update.

Step 3 - Build and Upload the Extension Zip Archive Using the UIP VS Code Extension

From the VS Code command palette, execute the UIP: Push command as shown below:

...

Expand
titleClick here to expand uip-cli details...

Step 3 Supplemental - Build and Upload the Extension Zip Archive Using the CLI

Save all changes to extension.py.

From the command line, cd to the ./sample-1 directory and execute the push command as shown below:

Recall that the push command builds and uploads the Extension zip archive

Step 4 - Launch task and observe the output only fields 

From the VS Code command palette, execute the UIP: Task Launch No Wait command as shown below: 

...

This was accomplished by the calls to ui.update_output_fields(out_fields) in the extension_start method in extension.py.

Step 5 - Update the Local template.json

In step 1, we modified the Universal Template by adding new Output Only Fields. Recall that inside ~/dev/extensions/sample-task/src/templates, there is a template.json file. This file should correspond to the Universal Template in the Controller. 

Right now, they are not both the same. The Controller's version of template.json has the Dynamic Choice Fields changes. To grab those changes, use the pull command as shown below:

UIP VS Code Extension

Expand
titleClick here to expand uip-cli details...

Step Supplemental - CLI


Now, both the local and Controller's version of the Universal Template are the same.

< Previous     Next >