Versions Compared

Key

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


Excerpt

This document explains briefs you on how to access the details of issue and transition objects in Jira expressions, such as those available through the issue and transition variables. To see an example of the structure of an issue go to <base_URL_of_Jira>/rest/api/latest/issue/{issueKey}. The fields displayed through this REST API actually depend on the fields set on the issue


Structure of an issue object

An issue object consists of the issue key and a collection of fields. The To know the structure of the issue object (such as those available through the issue, sourceIssue issue and linkedIssue variables)  is the same as that returned by the /rest/api/latest/issue REST resource documented here

...

borderStylesolid

issue object

...

Description: The issue object is an object with the following fields.

Structure :

...

titleClick here to see the structure of issue variable

...

Code Block
titleStructure
linenumberstrue
{
    "expand": String, //Parts of response
    "id":String, //ID of the issue.
    "self":String, //URL of the issue.
    "key":String, //Key of the issue.
    "fields": 
    {
		...
		...
	}
}

...

width700px
Code Block
titleExample
linenumberstrue
{
    "expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
	"id":"30101",
	"self":"https://jmwe-test-2.atlassian.net/rest/api/latest/issue/30101",
	"key":"TEST-628",
	"fields":
    {
		...
		...
	}
}

Accessing issue details using Nunjucks

Structure of the transition variable

The transition variable describes the current workflow transition. You might want to look at the log entries of a post-function execution to see the structure. The transition of an issue consists of the following fields :

...

transitionName

...

Description : The name of the current transition.

Structure :

...

titleClick here to see the structure of transitionName field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"transitionName": String, //Name of the transition
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"transitionName": "Start Progress",
		...
	},
}

...

  • Name of the transition - {{transition.transitionName}}

...

transitionId

...

Description : The ID of the current transition.

Structure :

...

titleClick here to see the structure of transitionId field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"transitionId": String, //ID of the transition
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"transitionId": "10000",
		...
	},
}

...

  • {{transition.transitionId}}

...

from_status

...

Description : The status from which the current transition starts.

Structure :

...

titleClick here to see the structure of from_status field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"from_status": String, //From status of the transition
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"from_status": "Open",
		...
	},
}

...

  • {{transition.from_status}}

...

to_status

...

Description : The status to which the current transition leads

Structure :

...

titleClick here to see the structure of to_status field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"to_status": String, //To status of the transition
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"to_status": "Done",
		...
	},
}

...

  • {{transition.to_status}}

...

workflowName

...

Description : The name of the workflow the transition belongs to.

Structure :

...

titleClick here to see the structure of workflowName field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"workflowName": String, //Workflow name of the transition
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"workflowName": "TEST Workflow",
		...
	},
}

...

  • {{transition.workflowName}}

...

workflowId

...

Description : The ID of the workflow the transition belongs to.

Structure :

...

titleClick here to see the structure of workflowID field

...

Code Block
titleStructure
linenumberstrue
{
	"transition":
	{
		...
		"workflowId": String, //Workflow ID the transition belongs to
		...
	},
}

...

width700px
Code Block
titleExample
linenumberstrue
{
	"transition":
	{
		...
		"workflowId": "10000",
		...
	},
}

...

returned in Jira expressions:

  1. Go to the Jira expressions editor
  2. Test the following code against an issue

    Code Block
    languagejs
    issue


  3. The result shows the issue structure as a JSON.

Not all data types are supported in Jira expressions. See here to find all the Data types supported in Jira expressions along with their properties and methods.

Access the fields of an issue

To write a Jira expression that accesses the fields of an issue, the easiest way is to use the "Issue Fields" tab in the Jira expressions editor help. To see the properties and methods of the returned value use the "Data Types" tab in the editor. For example, to access the "Assignee" field of an issue using the Jira expressions:

  1. Click on "Issue Fields" tab.
  2. Select the "Assignee" field from Select a field; the help shows you how to access the field, its sub-fields and test the field value.
  3. Click on one of the expressions to insert it into the editor; the help shows you the supported properties and methods of the returned Data Type.

Another way is to go to the "Data Types" tab of the Jira expressions editor and select "Issue" from "Select a Data Type" field. The help lists properties and methods of the Issue data type. Click on a button to insert it into the editor; hover over it to get the information. 

Structure of the transition variable

The transition variable describes the current workflow transition. It contains information about the transition that is currently happening and allows to inspect the source and target status. The transition of an issue consists of the following fields:

  • id: The transition ID (Number).
  • name: The transition name (String).
  • from: The current status of the issue (IssueStatus).
  • to: The target status of the transition (IssueStatus)
  • hasScreen: true if there is a screen configured for this transition, false otherwise (Boolean)

Use the "Global Variables" tab of the Jira expressions editor to access the current transition information.