Versions Compared

Key

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

This page explains how to access the value of Predefined custom 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.

...

Panel
borderStylesolid

Flagged

  • Field name: Flagged

  • Description: The Flagged field is an array of objects. Each object represents an option of the checkbox. By default, there's only one possible value: Impediment

  • Structure:

    Expand
    titleClick here to see the structure of the Flagged field


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
        ...
        ...
        "fields":
        {
            ...
            ...
    		customfield_xxxxx
    		[
            	{
                	"self":String, //URL of the choice
                	"value":String, //Value of the choice
                	"id":String //ID of the choice
    			}
    		]
          },
            ...
        }
        ...
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		....
    		....
    		"customfield_11300":
    		{
    			"self":"https://jmwe-test-2.atlassian.net/rest/api/2/customFieldOption/10600",
    			"value":"Impediment",
    			"id":"10600"
    		},
    		...
    	}
    	...
    }





  • Accessing the Flagged field
    • The value of the last option selected in the Flagged field

      Code Block
      {{ issue.fields["Flagged"] | last | field("value") }}


    • Display the values of all selected options, separated by a comma:

      Code Block
      {{ issue.fields["Flagged"] | join(",","value") }}


    • Test whether the issue has been flagged:

      Code Block
      {{ issue.fields["Flagged"] | find({"value":"Impediment"}) != null }}


...

Panel
borderStylesolid

Approvals

  • Field name: Approvals

  • Description: The Approvals field is a string representation of a multi-line text describing the search options for Jira Service Desk approvals information.

  • Structure:

    Expand
    titleClick here to see the structure of the Approvals field


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_xxxxx":String,
    		...
    	}
    	...
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_10002":"com.atlassian.servicedesk.plugins.approvals.internal.customfield.ApprovalsCFValue@195c4e9",
    		...
    	}
    	...
    }





  • Accessing the Approvals field: Accessing this field is not of much use.

...

Panel
borderStylesolid

Approvers

  • Field name: Approvers

  • Description: The Approvers field is an array of object. Each object represents an approver.

  • Structure:

    Expand
    titleClick here to see the structure of the Approvers field


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_xxxxx":
    		[
    			{
    				"self": String, //URL of the approver
    				"nameaccountId": String, //NameAccountId of the approver
    				"key": String, //Key of the approver
    				"emailAddress": String, //Email address of the approver
    				"avatarUrls": //URLs of approver avatar
    				{
    					"48x48": String,
    					"24x24": String,
    					"16x16": String,
    					"32x32": String
    				},
    				"displayName": String, //Display name of the approver
    				"active": Boolean, //True if approver is active
    				"timeZone": String, //Timezone of the approver
    				"accountType": String //Account type
    			},
    			{
    				//Second approver details and so on..
    			}			
    		],
    		...
    	}
    	...
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_10100":
    		[
    			{
    				"self": "https://jmwe-test-2validationenvironment.atlassian.net/rest/api/2/user?usernameaccountId=Corners5ca5b1469a000c1180956957",
    				"nameaccountId":"Corners", 				"key":"corner"accountId:5ca5b1469a000c1180956957",
    				"emailAddress":"c@gmail.com",
    				"avatarUrls":
    				{
    					"48x48":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=48",
    					"24x24":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=24",
    					"16x16":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=16",
    					"32x32":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=32"
    				},
    				"displayName":"Corners",
    				"active":true,
    				"timeZone":"Europe/Berlin",
    				"accountType": "atlassian"
    			},
    			{
    				//Second approver details and so on..
    			},			
    		],
    		...
    	}
    	...
    }





  • Accessing the Approvers field
    • Name of the last approver of the issue: {{ issue.fields.Approvers | last |field("nameaccountId") }}

    • On reopening an issue, set the assignee to the user selected on the transition screen, only if the user belongs to the approvers. If not, set the assignee field to the first approver:

      Code Block
      titleExample
      linenumberstrue
      {% set assignee = issue.fields.Assignee.nameaccountId %}
      {% set users = issue.fields.Approvers %}
      {% set var = false %}
      {% for user in users %}
      	{% if user.nameaccountId == assignee %}
      		{% set var = true %}
      	{%endif%}
      {% endfor %}
      	{% set var = true %}
      {% if not var %}
      	{%set firstuser = users | first %}
      	{{ firstuser.nameaccountId }}
      {%endif%}

      Select Ignore empty value option in the post-function configuration, so as to not clear the field if the value is empty or null.

    • Display all the users in the approvers field with their display name and email address separated by a hyphen:

      Code Block
      {% set users = issue.fields.Approvers %}
      {% for user in users %}
      	{{ user.displayName }} - {{ user.emailAddress }}
      {% endfor %}


...

Panel
borderStylesolid

Customer Request Type

  • Field name: Customer Request Type

  • Description: The Customer request type field represents an object describing the information about the Service Desk used to create the ticket.

  • Structure:

    Expand
    titleClick here to see the structure of the Customer request type fields


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_xxxxx":
    		{
    			"_links":
    			{
    				"jiraRest": String, // URL of the rest api
    				"web": String, //URL of the ticket
    				"self": String //URL of the request
    			},
    			"requestType":
    			{
    				"id": String, //ID of the request type
    				"_links":
    				{
    					"self": String //URL of the request type
    				},
    				"name": String, //Name of the request type
    				"description": String, //Description of the request type
    				"helpText": String, //Help text of the request type
    				"serviceDeskId": String, //Service desk ID
    				"groupIds":[String], //Array of group ID's
    				"icon":
    				{
    					"id": String, //ID of the icon
    					"_links":
    					{
    						"iconUrls":
    						{
    							"48x48": String, //URL of the icon avatar
    							"24x24": String, //URL of the icon avatar
    							"16x16": String, //URL of the icon avatar
    							"32x32": String //URL of the icon avatar
    						}
    					}
    				}
    			},
    		},
    		...
    	},
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_10023":
    		{
    			"_links":
    			{
    				"jiraRest":"https://jmwe-test-2.atlassian.net/rest/api/2/issue/30333",
    				"web":"https://jmwe-test-2.atlassian.net/servicedesk/customer/portal/3/PSDF-25",
    				"self":"https://jmwe-test-2.atlassian.net/rest/servicedeskapi/request/30333"
    			},
    			"requestType":
    			{
    				"id":"18",
    				"_links":
    				{
    					"self":"https://jmwe-test-2.atlassian.net/rest/servicedeskapi/servicedesk/3/requesttype/18"
    				},
    				"name":"Get IT help",
    				"description":"Get assistance for general IT problems and questions [example]",
    				"helpText":"Get assistance for general IT problems and questions [example]",
    				"serviceDeskId":"3",
    				"groupIds":["7"],
    				"icon":
    				{
    					"id":"10527",
    					"_links":
    					{
    						"iconUrls":
    						{
    							"48x48":"https://jmwe-test-2.atlassian.net/secure/viewavatar?avatarType=SD_REQTYPE&size=large&avatarId=10527",
    							"24x24":"https://jmwe-test-2.atlassian.net/secure/viewavatar?avatarType=SD_REQTYPE&size=small&avatarId=10527",
    							"16x16":"https://jmwe-test-2.atlassian.net/secure/viewavatar?vatarType=SD_REQTYPE&size=xsmall&avatarId=10527",
    							"32x32":"https://jmwe-test-2.atlassian.net/secure/viewavatar?	
    							avatarType=SD_REQTYPE&size=medium&avatarId=10527"
    						}
    					}
    				}
    			},
    		},
    		...
    	},
    }





  • Accessing the Customer request type field
    • Name of the Customer request type: {{ issue.fields['Customer Request Type'].requestType.name }}

    • Description of the Customer request type: {{ issue.fields['Customer Request Type'].requestType.description }}

...

Panel
borderStylesolid

Request participants

  • Field name: Request participants

  • Description: The Request Participants is an array of objects. Each object represents a participant.

  • Structure:

    Expand
    titleClick here to see the structure of the Request Participants field


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_xxxxx":
    		[
    			{
    				"self": String, //URL of the participant
    				"name": String, //Name of
    the participant
    				"keyaccountId": String, //KeyAccountId of the participant
    				"emailAddress": String, //Email address of the participant
    				"avatarUrls": //URLs of participant avatar
    				{
    					"48x48": String,
    					"24x24": String,
    					"16x16": String,
    					"32x32": String
    				},
    				"displayName": String, //Display name of the participant
    				"active": Boolean, //True if participant is active
    				"timeZone": String, //Timezone of the participant
    				"accountType": String //Account type 
    			},
    			{
    				//Second participant details and so on..
    			}			
    		],
    		...
    	}
    	...
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_10100":
    		[
    			{
    				"self": "https://jmwe-test-2validationenvironment.atlassian.net/rest/api/2/user?usernameaccountId=Corners5ca5b1469a000c1180956957",
    				"nameaccountId":"Corners", 				"key":"corner"accountId:5ca5b1469a000c1180956957",
    				"emailAddress":"c@gmail.com",
    				"avatarUrls":
    				{
    					"48x48":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=48",
    					"24x24":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=24",
    					"16x16":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=16",
    					"32x32":"https://secure.gravatar.com/avatar/316a26014c6e203f76d222f326462753?d=mm&s=32"
    				},
    				"displayName":"Corners",
    				"active":true,
    				"timeZone":"Europe/Berlin",
    				"accountType": "atlassian"
    			},
    			{
    				//Second participant details and so on..
    			},			
    		],
    		...
    	}
    	...
    }





  • Accessing the Request Participants field
    • Name of the first participant: {{ issue.fields['Request participants'] | first | field("nameaccountId") }}


Panel
borderStylesolid

Satisfaction

  • Field name: Satisfaction

  • Description: The Satisfaction field is a string representation of a multi-line text describing the request feedback in Service Desk requests.

  • Structure:

    Expand
    titleClick here to see the structure of the Satisfaction field


    Section


    Column


    Code Block
    titleStructure
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_xxxxx": String,
    		...
    	}
    	...
    }



    Column
    width700px


    Code Block
    titleExample
    linenumberstrue
    "issue":
    {
    	...
    	...
    	"fields":
    	{
    		...
    		...
    		"customfield_10025":"com.atlassian.servicedesk.internal.api.customfields.feedback.RequestFeedbackCFValue@d3f24"
    	...
    	}
    	...
    }





  • Accessing the Satisfaction fieldAccessing this field is not of much use.

...