Versions Compared

Key

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

...

Work Item Fields

Work Item Fields custom fields are used to provide for additional information to your work item. on work item. Field definitions are organized in groups. Work item page will display these custom fields in individual group tab, where user can enter values for fields. Field values can also setup using various scripting mechanisms on pipeline and webhook functions. The “Details” work item field group is created by default. To create a custom field:

  1. Select a Work Item Field Group or create a new one. The name of the field group first.

    1. You can create new work item field group by using Create new Work Item Field Group option from drop down.

    2. Field group tab will display after the “Commits” section when viewing a work item.

  2. Click Create to add a new field.

  3. Customize the field with various parameters and/or groovy validationsscript code. This is the definition of the field, while the value is set on the work item.

  4. Select one or more Work Item Types. Field will only be associated with work item of specific type based on this selection.

  5. Once you enter field definition details, click Save (or use CTRL + S shortcut).

...

Edit Field Definition

Work item fields containing the following properties:

Property Name

Required

Description

Code

Yes

Work item field code. Uniquely identifies the field.

Display Name

No

Work item display name.

Description

No

Work item description.

Work Item Types

Yes

The work item types this field will apply to. In other words, if a field is assigned the “Feature” Work Item Type, then all Work Items of type “Feature” will display that field. One or more Work Item Types can be set.

Field Group

Yes

Work item field group. The group which contains the current field. The field group name will appear as a section on the work item.

Field Data Type

Yes

Work item field data type sets the visual format of the field on UI along with simple validation. For more complex validation see “Validation Script”.

The following data types are supported: Script data type is provided in parentheses.

  • Text Field (String)

  • Text Area (String)

  • Number (Long) - UI validation will only allow integers / whole numbers

  • Decimal (Double) - UI validation will allow both integers and floating point numbers

  • Checkbox (Boolean) - True / False boolean field

  • Duration (Long) - Duration is the measure of time. Ui validation will only allow unit of measure formats. I.E. +2d or -3w

  • Date (Date) - UI validation expects mm/dd/yyyy format

  • DateTime (TimeStamp) - UI validation expects mm/dd/yyyy hh:mm am/pm. The date time is selectable from a calendar for ease of use.

  • URL (String) - UI validation expects a valid URL

  • JBDCURL (String) - UI validation expects a valid JDBC URL. See packageDeploy (JDBC) for examples of valid JBDC url.

  • Directory (String)

  • User Select (Username or User Id) (String or Long) - UI provides a selection from FlexDeploy users. Value passed to the work item can be username or user id.

  • Group Select (Group name or Group ID) (String or Long) - UI provides a selection from FlexDeploy groups. Value passed to the work item can be name or id.

Example of how each input would display on the work item

Definition Script

No

Work item definition Definition script . This is a groovy script that is used to set various values like defaults or basic validationsinitialize or update value for the field. Additionally, you can set or override basic validations like required, disabled, hidden, maxValue, minValue, maxLength etc. For example, if field is required only based on certain value of other field then you can achieve that by using definition script. You can also make field disabled based on current user’s roles using definition script.

Note that there is no return data from this script, but you will set field.value or field.state.

When you change field value, definition script is executed for all other fields, which allows you to reset value for other fields if necessary. Keep in mind that field.value setting will adjust value of the field on new work item as well as when work item is being updated. If you do not want to adjust the value once it is set then it must be accounted for in definition script, see empty check in example below.

Example definition script to set default value for the property based on work item type:

Code Block
languagegroovy
// empty check - in this example we will not set field value once it has been initialized
if (field.value == '' || field.value == null) 
{
   if (form.type.equalsIgnoreCase("Emergency")) 
   {
      field.value = "Priority 1"
   }
   else  if (form.type.equalsIgnoreCase("Expedite")) 
   {
      field.value = "Priority 2"
   }
   else  if (form.type.equalsIgnoreCase("Normal")) 
   {
      field.value = "Priority 3"
   } 
   else 
   {
      field.value = "Priority 4"
   }
}

Definition script evaluates for all fields when value is changed for any field. You can set field.value in Definition script to adjust the value.

Example definition script to hide field based on another field. Note that field.state in only available in Definition script.

Code Block
languagegroovy
// Hide Field based on other field value
if (form.OTHER_FIELD_CODE.equals("SOME_VALUE")) 
{
  field.state.hidden = true
}

List Data Script

No

Work item list data script. This is a groovy script which defines a set of options the user can choose from for this fields field value. List Data Script will only apply to String based fields i.e. TextField and not DateTime.

The script is expecting one of 3 return typesYou can return list data in 3 different ways (see below):

Code Block
// An array of values
return ["PROD", "NON-PROD"]

// A comma separated string
return "Break Fix,Enhancement,Problem,Project,request,Risk remediation"

// An array of ListValueDataObject
// Use the constructor or setters on the ListValueDataObject objects to set appropriate values
return [new ListValueDataObject("value1"),  new ListValueDataObject("label2", "value2"), new ListValueDataObject("label3", "value3", "Description")]


////////////////////////////////////////////////////////////////////////////////////
// ListValueDataObject has the following variables
  public ListValueDataObject(String pLabel, String pValue, String pDescription)
  public ListValueDataObject(String pLabel, String pValue)
  public ListValueDataObject(String pValue)

Validation Script

No

Work item validation script. This is a groovy script allowing allows for more complex validations beyond simple UI validations like isRequired required or min/max value etc.

Return false to indicate validation failure. In addition set ValidationMessage variable with custom error message which will be displayed for user.

Example Date based Validation script:

Code Block
languagegroovy
// Validation script must return or true or false
// ValidationMessage is a variable specific to this script which will be display on the UI if this script returns false
if (form.PLANNEDSTART != null && form.PLANNEDEND != null) 
{   
  if (form.PLANNEDEND.before(form.PLANNEDSTART)) 
  {
    ValidationMessage = "Planned end date is not before start date ."
    return false
  }
}
return true

This When field value is changed,

  • this script is executed

when the status of a work item is changed. Status change will not go through if the validation script fails
  • for the field being updated, and if it returns false then value change is not allowed.

  • validation script is executed for all other fields as well, field value change will still be allowed if any validation failure occurs for other fields, and screen will show updated error messages.

When work item status is changed,

  • This script is executed is execution for all fields and if any script returns false then status update will not be allowed.

Field Script Objects and Variables

Definition, List Data, and Validation Script have access to the following variables and methods which can used to retrieve values of other fields, set the value of the current field, and other functions to achieve your business requirement.

ObjectsVariables

Type

Description

formjava.util.Map

Allows access to other fields value form details displayed on work item page. For example, field values and work item value for details like title, description, status, type, assignee and tags.

field

flexagon.fd.model2.pojo.common.FieldDataObject

Set see details below in form section

field

Represents current field value and allows for override properties value for of required, hidden, disabled, maxValue, minValue and maxLength.

see details below in field section

currentUser

flexagon.fd.model2.pojo.common.CurrentUser

Returns CurrentUser object with methods - getUserId(), getUserName(), getFirstName(), getLastName(), getEmail() and getRoles()

FLEXDEPLOY

flexagon.fd.services.groovy.functions.IFlexDeployFunctions

Functions for performing actions in Provides various methods to retrieve data from FlexDeploy.

EMAIL

flexagon.fd.services.groovy.functions.EmailFunctions

Functions for formatting and sending emails.

REST

flexagon.fd.services.groovy.functions.RestFunctions

Object exposing REST functions. For more info see Using the REST object. You can use this to invoke external systems for gathering details and/or validations.

TOPOLOGY

flexagon.fd.services.groovy.functions.TopologyFunctions

Allows access to Integration Accounts (such as Source Control, Change Management, Cloud, or other tools) properties. You can use this in conjunction with REST function to invoke external systems APIs.

Variables for the form object (note that form data can not be changed from scripts)

Variables

Type

Description

form.title

java.lang.String

Returns the value of the Title for the work item.

form.description

java.lang.String

Returns the value of the Description for the work item.

form.changeField

java.lang.String

Property key name of Code for changed field for the current work item, available when one field value is changed.

form.status

java.lang.String

Returns the value of the Status name for the work item.

form.type

java.lang.String

Returns the value of the Type code for the work item.

form.tags

java.util.List

Returns the value of the Tags for the work item.

form.<keycode>java.io.Serializable

depends on field data type

String, Long, Double, Boolean, Date, Timestamp

<keycode> represent code of specific field. All fields field values of work item can be referenced this way.

form.assignee

java.lang.String

Returns the value of the username for Assignee for the work item.

Updating of state or and value of field is allowed from Groovy Definition script.

Variables

Type

Description

field.name

java.lang.String

Returns the current field name.

field.datatype

java.lang.String

Returns the current field data type.

field.value

java.io.Serializable

Updates

depends on field data type

String, Long, Double, Boolean, Date, Timestamp

Update the current field value by assigning new value as necessary. Obviously field.value represent current value of the field as well.

Code Block
languagegroovy
if (field.value == '' || field.value == null) 
{
   if (form.type.equalsIgnoreCase("Emergency")) 
   {
      field.value = "Priority 1"
   }
   else 
   {
     field.value = "Priority 2"
   }
 } 

field.state.required

java.lang.Boolean

Overrides the current field required property. True or False.

Code Block
languagegroovy
if (form.DOWN_TIME_REQUIRED!= null &&  form.DOWN_TIME_REQUIRED== true) 
{
    field.state.required = true;
} 

field.state.disabled

java.lang.Boolean

Overrides the current field disabled property. True or False.

Code Block
languagegroovy
if (field.value != '' && field.value != null) 
{
    field.state.disabled = true;
}

field.state.hidden

java.lang.Boolean

Overrides the current field hidden property. True or False.

Code Block
languagegroovy
// Hide field based on other field value.
if (form.VENDOR_NOT_FOUND != null &&  form.VENDOR_NOT_FOUND == false) 
{
      field.state.hidden = true      
}  
 

field.state.maxValue

java.lang.Long

Overrides the current field maxValue property.

Code Block
languagegroovy
  field.state.maxValue = 10000

field.state.minValue

java.lang.Long

Overrides the current field minValue property.

Code Block
languagegroovy
  field.state.minValue = 100

field.state.maxLength

java.lang.Long

Overrides the current field maxLength property.

Code Block
languagegroovy
  field.state.maxLength = 255