Versions Compared

Key

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

...

{
  "array_1": [
    { "My_element_2": "Value 1" },
    { "My_element_2": "Value 2" }
  ]
}

Code Example

...

Code Block
languagepy
linenumberstrue
# Get and print array_1

...


print('Array 1:')

...


...

array_1 = fields.get("array_1", [])

...


...

# The array is stored as a list of dicts - each containing a

...

 
# single key/value pair indicating the 'name' and 'value' for

...

 
# the given array element.

...


for row_dict in array_1:

...


    for k,v in row_dict.items():
        

...

# Print the array element 'name' and 'value'.

...


        print('{0}\t{1}'.format(k,v))

...

Choice Type Field

Fields defined in a Universal Template as type Choice will have a value of type list in the fields dict. The elements of the list will be the values associated with the selected “choices” in the associated task instance. The values will be of type str. For example:

{
  "choice_1": [ "choice value" ]
}

Code Example

...

Code Block
languagepy
linenumberstrue
# Get the value of the 'action' field

...

choice_value = fields.get('choice_1', [""])[0]

...

Script Type Field

Fields defined in a Universal Template as type Script will have a value of type str in the fields dict. At execution time, UAG will write the Data Script associated with the Script type field to the file system. The path to that Data Script file on the local file system is what is passed in the field value. For example:

...

The Credential values in the fields dict can be referenced as follows:

...

Code Block
languagepy
linenumberstrue
user = fields[“credential_1"]["user"]
password = fields["credential_1"]["password"]

...

Key to Field Mapping

The key value pairs in the Credential dict represent the similarly named fields that make up a Credential definition in the Controller. Below is a mapping of dict key name to Credential field name in the Controller.

...

The SAP Connection values in the fields dict can be referenced as follows:

...

Code Block
languagepy
linenumberstrue
ashost = fields[“sap_connection"]["sap_ashost"]
sysnr = fields["sap_connection"]["sap_sysnr"]
client = fields[“sap_connection"]["sap_client"]

...

Key to Field Mapping

The key value pairs in the SAP Connection dict represent the similarly named fields that make up an SAP Connection definition in the Controller. Below is a mapping of dict key name to SAP Connection field name in the Controller.

...