Select Page

A story about a place of joy

Let me tell you a story about a place of joy, and a pair of colleagues who worked there, the mighty Product Manager and a modest Jira administrator.

Once upon a time, beyond the seven hills of tasks, beyond the seventh deadline, there was an office in a cottage where dwarves were creating software. Among the dwarves, some served with the customers in a support team. Others were developers bravely shaping untamable code into something that pleased the customers. At the end of every sprint, the mighty Product Manager would attend a demo. Usually, the Product Manager looked over all he and his dwarves had made, and he saw that it was very good! And evening passed and morning came, marking the release day that made the customers happy.

As usual, the customers, having worked with the new version of the software for a while, flooded the dwarves with new feature suggestions. The dwarves stored the suggestions in a system they used solely to communicate with the customers and keep track of their bug submissions and ideas for new product features. The system was not integrated with the Jira that the developer dwarves and the mighty Product Manager were using. The world was not perfect, since evil has not been completely eradicated yet.

The mighty Product Manager

The mighty Product Manager’s task, in all his wisdom, was to shape the product’s roadmap and backlog continuously. Without the roadmap, the developer dwarves’ efforts could produce features that were not quite important for a large enough number of customers. One of the things the Product Manager was doing to get the roadmap right was to browse the other system’s feature suggestions and create user stories in Jira based on them. He then linked the feature suggestions to the user stories in Jira through issue web links.

There were already hundreds of user stories in the product backlog, and the PM managed their order of implementation manually. Wanting to make things better, he walked into the Library of Knowledge of Great Product Managers, his ancestors. After many evenings and long reading sessions, he found information about metrics that he could use to prioritize the roadmap. One of these metrics was the number of customers interested in a given feature.

“A-ha!”

he exclaimed!

“I already have this information in my user stories! Now it’s enough to count the number of web links leading from each user story to its originating feature suggestions and sort the stories based on that number. Then I will know which user stories are the most desired.”

He poured some whisky into his glass, took a sip, lighted up a cigar, took a puff, and thought

“If only I knew how to do this in Jira… Bring me the Jira administrator!”

he shouted, knowing he was getting closer to a solution.

Requirements talk in practice

As the Jira administrator was sitting at his desk, adding access to a project for the 283rd user from a printed list delivered by the accounting elves, a messenger ran into his room.

“The mighty Product Manager wants to see you. Now! Oh… If you want to handle users in bulk, read this later. And now let’s go!”

They both ran to see him and delved into a conversation about the nature of the problem.

“I know exactly how to implement what you need”

said the Jira admin.

“We need a scripted field on a user story, which will display the number of web links to feature suggestions that story. Then, on your dashboard, I will add a table showing the user stories sorted in descending order by that new field. And that’s it. You will see the most desired user stories at the top, and take this into account when creating the product roadmap”.

The Product Manager smiled slightly, looking at the Jira admin with content. They sat in silence for a few seconds, which felt like an eternity to the Jira admin. He knew the question was coming…

“How quickly can you get it done?”

the PM he inquired. Being already quite familiar with ScriptRunner, and Groovy for Jira, the Jira administrator was confident.

“I will have it ready tomorrow morning” he stated.

“Tomorrow is Saturday” said the Product Manager.

“It does not matter. My Netflix account got suspended” the Jira admin replied.

“So it be. You have nothing better to do anyway. Tomorrow morning it is!” said the Product Manager.

Back to the Jira admin’s lair

After getting back to his lair, the Jira admin wanted to refresh his knowledge before getting to work. He poured some Yerba Mate into his cup. “It’s going to be a long and productive night” he thought, looking at the suspended Netflix account. “Bastards! Sharing is caring!” he thought. The Jira admin browsed the scripted field documentation, which was beautifully easy to read, and after taking a sip, he knew exactly what to do. He stretched his fingers, yawned, and got to work.

He created a few test user stories and added a few web links to each. The first one had zero web links simulating a link to a feature suggestion, the second had just one, and the third had 5 of them. He then added a few web links to the third user story that did not represent feature suggestions. He wanted to be sure that these would not be taken into account. After all, it would not be desirable to lift a user story in priority just because there were some irrelevant web links in them. The feature suggestions always had a specific form of the URL:

 

 

Add Jira web link
Add web link to Jira issue
User story with 5 web links

He then clicked the dot (“.”) on his keyboard to enter the quick-search menu and typed in “fields”. Jira obediently returned some options. He chose “Scripted fields”.

 

Jira find script fields in the search menu

He then clicked the “Create script field” button and chose “Custom script field” from the list. He called his field “Number of support tickets” gave it a description, and chose “Number Field” as the template since his new field was supposed to display a number.

 

Create custom script field in Jira Scriptrunner by Adaptavist

“Time to do some scripting!”

he thought.

Minutes and hours passed like seconds, as the admin was forging his code. He admired the finesse with which the developer dwarves built their code. After a few refills of Yerba Mate, a few too many looks at the suspended Netflix account, and a few pee-breaks, he was finally ready.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager

def rlm = ComponentAccessor.getComponentOfType(RemoteIssueLinkManager.class)

def urlList = rlm.getRemoteIssueLinksForIssue(issue)*.getUrl()

return urlList.findAll { it -> it.matches("(.*)FS-(.*)") }.size()

Yes, he was not a good coder, so his coding speed was not that great. But his code seemed correct, and he was proud to have used regular expressions to find the URLs containing the “FS-” substring. He needed to be sure if the code works, so he tested it. He used the “Preview Issue Key” field to enter the issue keys of the stories he’d created earlier. Here is what he saw for GFJA-23:

 

Test script field

It was precisely 5 web links, excluding the link leading to Netflix alternatives, so the result was correct. Other issues keys returned accurate results, too, so he decided to add the field by clicking the “Add” button at the bottom.

 

Add script field

He saw a message saying:

 

Scriptrunner message

He was lazy enough to leave the context global, which was not the best he could do, and clicked “Configure Screens” and added his new field to the screen used by the user story issue type in the Product Manager’s project. He refreshed the page on the user story issue view, and he saw:

 

script field shown in user story issue view

Jira displayed the value correctly. He then wanted to display a list of user stories sorted by the number of support tickets, but it turned out the field was not accessible in JQL. After checking why he found out, the script field’s custom field does not have a search template. In the custom fields’ edit mode, he set the search template:

 

set search template for the custom field

And tried sorting the stories in the issue finder:

User stories sorted in issue navigator by the number of linked support tickets

“Easy-peasy”

he thought with pride and created a filter result gadget based on this search on the Product Manager’s dashboard.

“I look at what I had made, and I see that it is very good!”

he thought.

“Time to show this to the mighty Product Manager!”

he exclaimed, and ran out of his lair, heading towards the PM’s office.

And they have lived happily ever after.

 

Moral of the story

  1. Be useful to humanity.
  2. Learn the freakin’ scripting, and save your world.
  3. It’s not that hard!
  4. Especially that I’m here to help you.
  5. Use it.
  6. Wisely.
  7. Subscribe not to miss out.
  8. Talk to you later :)