Standard JIRA Fields

This page explains how to access the value of Standard Jira fields using Nunjucks. Each field's structure is explained with examples. To understand how to write values into these fields see, Text input for fields and JSON input for fields.

It is now possible to access the standard fields of an issue by its Field name or Key.

Example:

{{ issue.fields.watches.watchCount }} and {{ issue.fields.Watchers.watchCount }}, both return the number of watchers.

When the field name contains a space or any special character, you need to use the array syntax to access the field :

Example:

{{ issue.fields['Issue Type'].name }}

{{ issue.fields['Component/s'][0].name }}

 

Affects Version/s

  • Field name : Affects Version/s

  • Key: versions

  • Description : The Affects Version/s field is an array of objects. Each object represents a single version.

  • Structure :

     Click here to see the structure of Affect Version/s
    Structure
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"versions": 
    		[
    			{
    				"self":String, //URL of the versions
    				"id":String, //ID of the version
    				"description": String, //Description of the version
    				"name":String, //Name of the version
    				"archived":Boolean, //True when archived
    				"released":Boolean, //True when released
    				"releaseDate":String //Release date of the version
    			},
    			{
    				//Second version and so on.
    			}
    			...
    		],
    		...
    	}
    }
    Example
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"versions": 
    		[
    			{
    				"self":"https://jmwe-test-2.atlassian.net/rest/api/2/version/10601",
    				"id":"10601",
    				"description":"Trial Version",
    				"name":"2",
    				"archived":false,
    				"released":true,
    				"releaseDate":"2016-10-06"
    			},
    			{
    					...
    			}
    		...
    		],
    	}
    }

  • Accessing the Affects version/s field

    • First Affects Version name : {{issue.fields.versions[0].name}}

    • Last Affects Version name:

      {{ issue.fields.versions | last | field("name")}}

      where '|' is the pipe operator, 'last' and 'field' are filters. See Nunjucks annotations for more filters.

    • Join the names of the Affects Version/s, separated by commas: {{issue.fields.versions | join("," , "name")}}

    • Return all the Affects Version/s, in a format that can be used to set the Fix Version/s field : {{issue.fields.versions | dump(2)}}

    • Test whether "1.0" is in the Affects Version/s: {{ issue.fields.versions | find({name:"1.0"}) }}

 

Assignee

  • Field name : Assignee

  • Key: assignee

  • Description : The Assignee field is an object that represents the user who this issue is assigned to.

  • Structure :

     Click here to see the structure of Assignee field
    Structure
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"assignee": 
    		{
    			"self":String, //URL of the user
    			"accountId": String,
    			"emailAddress":String, //Email ID of the user
    			"avatarUrls": //URLs of assignee avatar
    			{
    				"48x48":String,
    				"24x24":String,
    				"16x16":String,
    				"32x32":String,
    			},
    			"displayName":String, //Display name of the user
    			"active":Boolean, //True when the user is active
    			"timeZone":String, //Time zone of the user
    			"accountType": String //Account type 
    		},
    	}
    }
    Example
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"assignee":
    		{
    			"self": "https://validationenvironment.atlassian.net/rest/api/2/user?accountId=5ca5b1469a000c1180956957",
    			"accountId": "accountId:5ca5b1469a000c1180956957",
    			"emailAddress":"rvijji@innovalog.com",
    			"avatarUrls":
    			{
    				"48x48":"https://jmwe-test-2.atlassian.net/secure/useravatar?avatarId=10337",
    				"24x24":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=small&avatarId=10337",
    				"16x16":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=xsmall&avatarId=10337",
    				"32x32":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=medium&avatarId=10337"
    			},
    			"displayName":"Radhika Vijji",
    			"active":true,
    			"timeZone":"Europe/Berlin",
    			"accountType": "atlassian"
    		},
    	}
    }

  • Accessing the Assignee field

    • AccountId of the Assignee : {{issue.fields.assignee.accountId}}

    • Timezone of the assignee : {{issue.fields.assignee.timeZone}}

 

Attachments

  • Field name : Attachment

  • Key: attachment

  • Description : Attachment is an array of objects. Each object represents a single attachment.

  • Structure :

     Click here to see the structure of Attachments
    Structure
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"attachment": 
            [
                {
                    "self":String, //URL of the attachment
                    "id":String, //ID of the attachment
                    "filename":String, //Name of the attachment
                    "author": //Author of the attachment
                    {
    		            "self":String, //URL of the author
    					"accountId": String,
         				"emailAddress":String, //Email ID of the author
          				"avatarUrls":
    				     {
               				"48x48":String, //URL of the author
                			"24x24":String, //URL of the author
                			"16x16":String, //URL of the author
                			"32x32":String, //URL of the author
            			},
            			"displayName":String, //Display name of the author
            			"active":Boolean, //True when the author is active
            			"timeZone":String, //Time zone of the author
    					"accountType": String //Account type 
                    },
                    "created":String, //Attachment created timestamp
                    "size":Number, //Size of the attachment
                    "mimeType":String, //Type of the attachment
                    "content":String, //Content of the attachment
                    "thumbnail":String //Thumbnail of the attachment
                },
            ],
    		...
    	}
    	...
    }
    Example
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"attachment":
    		[
    			{
    				"self":"https://jmwe-test-2.atlassian.net/rest/api/2/attachment/11001","id":"11001",
    				"filename":"one.png",
    				"author":
    				{
    					"self": "https://validationenvironment.atlassian.net/rest/api/2/user?accountId=5ca5b1469a000c1180956957",
    					"accountId": String,
    					"emailAddress":"rvijji@innovalog.com",
    					"avatarUrls":
    					{
    						"48x48":"https://jmwe-test-2.atlassian.net/secure/useravatar?avatarId=10337",
    						"24x24":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=small&avatarId=10337",
    						"16x16":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=xsmall&avatarId=10337",
    						"32x32":"https://jmwe-test-2.atlassian.net/secure/useravatar?size=medium&avatarId=10337"
    					},
    					"displayName":"Radhika Vijji",
    					"active":true,
    					"timeZone":"Europe/Berlin",
    					"accountType": String //Account type 
    					
    				},
    				"created":"2016-10-13T12:33:50.472+0200",
    				"size":31721,
    				"mimeType":"image/png",
    				"content":"https://jmwe-test-2.atlassian.net/secure/attachment/11001/one.png",
    				"thumbnail":"https://jmwe-test-2.atlassian.net/secure/thumbnail/11001/_thumb_11001.png"
    			}
    			{
    				//Second attachment and so on..
    				}
    		],
    		...
    	}
    	...
    }

  • Accessing the Attachment field

    • Size of the last attachment :

      {{ issue.fields.attachment | last | field("size")%}

      where '|' is the pipe operator, 'last' and 'field' are filters. See Nunjucks annotations for more filters.

    • Name of the Author of the first attachment : {{ issue.fields.attachment[0].author.accountId}}

 

Created

  • Field name : Created

  • Key: created

  • Description : The Created field is a string representation of a date.

  • Structure :

     Click here to see the structure of the Created field
    Structure
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"created":String, //Created datetime stamp
    		...
    	}
    	...
    }
    Example
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"created":"2016-10-13T08:10:16.644+0200",
    		...	
    	}
    	...
    }

  • Accessing the Created fields

    • Created date of the issue : {{ issue.fields.created }}

    • Format the created date : {{ issue.fields.created | date('fromNow') }}

You can use the date filter to manipulate and/or format the value