Set Ticket Priority Based on Asset Attributes

Scenario

When an ticket is opened in Jira Service Management, you want to set the Priority of the ticket based on the attached Asset’s attributes.

Note: This use case requires Jira Service Management and uses a custom Asset field. For more information on creating and configuring Assets in JSM, see this page.

Resolution

This requires that a custom field for an Asset has been added to your project; it can have any name and can represent any type of Asset, but it must be an Asset object to successfully use the steps as outlined. By accessing the Asset’s attributes, you can update the ticket’s priority when the ticket’s Asset meets specific critera; for example, if you have a networking device Asset with a Priority attribute set to ‘Critical’, any tickets created that have that Asset attached can automatically be assigned the highest priority.

Note: the steps below use an example Asset object with an attribute of Priority. You will need to modify the included script for your specific JSM setup.

Additionally, the script uses Jira Cloud’s Asset API to access the attribute values because these values are not accessible using the insightFieldValue custom Nunjucks filter. In order to access the attribute values through the Cloud API, you will need to provide your Atlassian username and an Access Token within the Nunjucks script.

You are viewing the documentation for Jira Cloud.

On This Page

Steps to Create

1. Add the Assets object custom field

Verify that your Jira project has a custom Assets object field, and that that field has been added to all necessary screens. Additionally, you will need to verify that it has been fully configured per the Atlassian instructions. If that custom field does not exist, create one and add it wherever is necessary for your processes; see this page for more information: Set up the Assets objects custom field | Jira Service Management Cloud | Atlassian Support .

2. Add Set issue fields post-function

  1. Log in to your Jira instance as an Administrator.

  2. In the upper right corner of the window, click Settings ( ) and select Issues.

  3. In the left-hand sidebar, click Workflows.

  4. From the list of Workflows, click Actions ( ) for the appropriate workflow and select Edit.

  5. Edit the transition:

    1. When viewing the Workflow in Diagram view (Figure 1, right), select the Transition and click the Post Functions link. Click Add post function at the top of the list of existing post functions.

    2. When viewing the Workflow in Text view, click the name of the Transition then select the Post Functions tab. Click Add post function at the top of the list of existing post functions.

    3. Select Set issue fields (JMWE app) from the list of post-functions and click Add.

setTicketPriority-EditTransition.png
Figure 1 - Edit Transition

 

3. Configure the post-function

Set the following configurations (Figure 2, right):

  1. Issue(s) to operate on - Set Target issue(s) to Current Issue.

  2. Set fields

    1. From the Add field(s) pulldown menu, select Priority. The Priority field will be added to the list of fields that will be updated by the post function.

    2. For the Priority field’s configurations, set the Options as needed.

    3. Also under the Priority field, use the following script for the Value:

      {% set assetURL = issue | insightFieldValue( "customfield_xxxxx", true ) | first | field("links.self") %} {% set assetPriority = assetURL | callRest(options = { "auth": { "username": "your email address tied to your Atlassian account", "password": "your Atlassian API token value" } }) | field("attributes") | filter({"objectTypeAttributeId":"the object attribute ID"}) | field("objectAttributeValues") | first | field("value") %} {% if assetPriority == "Critical" %} Highest {% else %} Medium {% endif %}
  3. Conditional execution - Set as needed.

  4. Run As - Set as needed; it is recommended to leave the default Add-on user value unless required for specific reasons.

  5. Delayed execution - Set as needed.

  6. Click Add.

setTicketPriority-ConfigurePostFunction.png
Figure 2 - Configure Post Function