Images in Jira Custom Fields - Part 1

Most people have never even considered the possibility of adding images to Jira custom fields. However, this can actually be done with Jira out-of-the-box if you know the tricks. However, by itself, it is not very useful. You need some automation behind it to create something powerful. And, believe me, you can create some really powerful solutions using images.

Action icons used in Jira Service Management queues

Every knows how useful the automation in Jira Service Management can be. However, there are times that these automations can let customers fall through the cracks. For example, most of the automations I have used in the past tend to update the issue status based on customer or agent actions. But what happens when you don’t want to update the status?

This is a real-world scenario that happened at a company I worked for and this is the solution we came up with. There were also other factors contributing to the requirements such as customers getting lost for other reasons. In general, the agents had a problem and needed to improve the visibility on issues that needed attention immediately.

Automations in this example:

  1. Whenever an issue is in theWAITING on Customerstatus and a customer adds a comment the status transitions toWAITING on SUPPORT

  2. Whenever an issue is in theWAITING on SUPPORTstatus and an agent adds a comment the status transitions toWAITING on Customer

  3. Whenever an issue is in thein progressstatus there are no automations attached

Notice that there are no automations in #3. This is because we don’t want to loose the status that indicates that it is in-progress and that someone is working on it. If we add automation it would automatically switch the status betweenWAITING on CustomerandWAITING on SUPPORTand there is no (good) way to get back to the in-progress status. However, if a customer adds a comment when the issue is in-progress the agent still needs to know about it and we are not relying on emails because they can be lost so easily. So how would we know that the agent should take action without loosing the in-progress status?

It is quite possible that there are other ways to solve this example using existing Jira Service Management automation. However, we needed to start with something…

The solution we came up with was a combination of “traffic lights” and other icons that the agents could quickly scan and see who needed attention. Notice the column furthest to the right in the screen shot below:

As you can see, the red circle indicates that those issues need attention and the green issues are good (don’t need attention). There is also a speech bubble icon that indicates that a customer was the last person to leave a comment on the issue and therefore the agent needs to respond to them.

This can be done using either a standard Jira text field and Power Scripts, or a SIL Script custom field and Power Custom Fields. The trick is to use wiki rendering on the custom field. If the field is then populated with the proper syntax it will cause an image to appear!

Since the SLA’s in Jira Service Management are always running, the best solution is actually using Power Custom Fields so that is the solution we will see in this blog. With Power Scripts the updates to the custom field need to be scheduled and it will only update every 30 minutes (for example) versus updating immediately with Power Custom Fields.

SIL Script

The key to getting an image to appear in the wiki rendered custom field is displaying a text string with the proper wiki syntax. The proper syntax is the image URL surrounded by exclamation points. Something like the text below:

!http://www.myimages.com/image!

For a very basic example we can use the code below that will use a standard Jira icon to display an image in a Power Custom Fields, SIL Script custom field:

return "!" + getJIRABaseUrl() + "/secure/viewavatar?size=xsmall&avatarId=10800&avatarType=issuetype!";

If the custom field is configured to render as wiki, this image should appear in almost anyone's Jira instance without any other setup.

Part 1 - File paths

For the first part of the script, we are going to create an indexed array of the file paths for the icons. You can get the file path by click the attachment link in the issue (see configuration steps below). We will use the index key to refer to the full path later in the code.

string [] icons; icons["green"] = "http://localhost:8080/secure/attachment/10001/green.png"; icons["yellow"] = "http://localhost:8080/secure/attachment/10002/yellow.png"; icons["red"] = "http://localhost:8080/secure/attachment/10003/red.png";

Part 2 - SLA

While we could just script logic similar to that which is used in the SLA, it would be better to use the actual SLA. This way, if updates are made to the SLA in Jira Service Management then this script will still be in sync with the SLA.

What we are doing in the code below is getting the information for the "Time to resolution" SLA and using it in the logic:

  • By default, the color is green

  • If the SLA is breached, the color is red

  • If there is less than 1 hour left in the SLA, yellow

Part 3 - Last comment

In this part of the cade we are getting the details of the last comment and using them in our logic:

  • By default, speech flag is false

  • Comment author can not be null

  • User (comment author) must exist

  • If the author is in the “Service Desk Team” project role, speech flag should be true

Part 4 - Putting it all together

This part is just combing all the other parts into a single script. At the end of this script we build the actual text string that will make up the wiki text.

Configuration

  1. Create a new SIL Script Custom Field using Power Custom Fields

  2. In the Jira Service Management project settings, edit the Field Configuration scheme

  3. For the custom field you created (we called it Action Status), click the Renders link in the right column

     

  4. Select Wiki Style Renderer and click Update

     

  5. Re-index Jira (background re-index is fine)

  6. Now, in order for the images to appear for us they must be hosted. This means they must already be part of a public website or somewhere in Jira that will allow them to appear in a webpage.

    1. Easy way - the easiest way is to create an issue in Jira in a project that everyone has access to and attach the images to that issue. Name the issue in such a way that people who see it won’t delete it.

      1. Pros

        1. Jira does not need to be restarted

        2. Quick and easy

      2. Cons

        1. It is possible someone might delete your issue

    2. Harder way - harder but maybe better. You can add the images into the Jira installation folder with the other icons.

    3. Pros

      1. It can not be impacted by someone accidently deleting your issue

      2. You can use built in Jira feature to dynamically scale the size of the image (not getting into this here)

    4. Cons

      1. You need to restart Jira in order for Jira to register the icons

      2. The icons folder gets replaced whenever Jira is upgraded

  7. For this example we will use a ticket in Jira to host the images. Just create a new ticket and attach the images:

     

  8. Now we can configure the custom field. In the field configurations click Edit SIL Script

  9. Copy the SIL script from above and paste it into the SIL Editor window

  10. Click Save

 

The configuration is now complete. You should see an image displaying in your custom field. If not, try re-indexing or checking your image paths.

Assets

See below for the images used in this example: