Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
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?
Info |
---|
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:
Whenever an issue is in the
status and a customer adds a comment the status transitions toStatus colour Green title WAITING on Customer Status colour Yellow title WAITING on SUPPORT Whenever an issue is in the
status and an agent adds a comment the status transitions toStatus colour Yellow title WAITING on SUPPORT Status colour Green title WAITING on Customer Whenever an issue is in the
status there are no automations attachedStatus colour Blue title in progress
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 between
Status | ||||
---|---|---|---|---|
|
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:
Code Block |
---|
!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:
Code Block |
---|
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.
Code Block |
---|
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
Code Block |
---|
string color = "green"; ... JSlaInformation[] slaInfos = getSlaInformation(key); for(JSlaInformation slaInfo in slaInfos) { if(slaInfo.name == "Time to resolution") { JSlaOngoingCycle slaOC = slaInfo.ongoingCycle; if(slaOC.breached) { color = "red"; } else if(slaOC.remainingTime < 3600000) { color = "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
Code Block |
---|
boolean speech = false; ... string [] lastCommentDetails = getLastComment(key); if(isNotNull(lastCommentDetails["author"]) && userExists(lastCommentDetails["author"])) { if(!isUserInRole(lastCommentDetails["author"], project, "Service Desk Team") && lastCommentDetails["author"] != "automation") { speech = true; } else { runnerLog("No user: " + lastCommentDetails["author"]); } } |
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.
Expand | ||
---|---|---|
|
Configuration
Create a new SIL Script Custom Field using Power Custom Fields
In the Jira Service Management project settings, edit the Field Configuration scheme
For the custom field you created (we called it Action Status), click the Renders link in the right column
Select Wiki Style Renderer and click Update
Re-index Jira (background re-index is fine)
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.
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.
Pros
Jira does not need to be restarted
Quick and easy
Cons
It is possible someone might delete your issue
Harder way - harder but maybe better. You can add the images into the Jira installation folder with the other icons.
Pros
It can not be impacted by someone accidently deleting your issue
You can use built in Jira feature to dynamically scale the size of the image (not getting into this here)
Cons
You need to restart Jira in order for Jira to register the icons
The icons folder gets replaced whenever Jira is upgraded
For this example we will use a ticket in Jira to host the images. Just create a new ticket and attach the images:
Now we can configure the custom field. In the field configurations click Edit SIL Script
Copy the SIL script from above and paste it into the SIL Editor window
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.
Contents
Table of Contents |
---|
Assets
See below for the images used in this example:
attachments