Save Your Company Thousands by Using Atlassian Forge to Write Your Own Workflow Comment Validator
The problem
One of the most frustrating things about Jira as an admin are the surprising little gaps that catch you up and end up requiring a Marketplace Partner to fill in the gaps - too early. Marketplace Apps are awesome and incredibly powerful, but if your company ends up buying too many too early, you will absolutely turn the company against them if you don't have high product usage.
It's crucial that Atlassian products remain affordable and effectively scalable as organizations onboard into them. This, my friends, is where Forge comes in. You can build all sorts of solutions to user needs so quickly - and without having to host anything!
LOOK AT THIS!!!!
SO.
My favorite example, and one that you've definitely run into as an admin or a user is the first time someone comes to you and says, “I want to require a comment when someone transitions from X to Y.”
"Okay," you think. "No problem. This must be possible out of the box!" So you go looking for it.
You look in the UI. Can't find it.
You read the docs. Nothing.
You search the internet. Lots of dead ends.
You go to this site we're on right now, and you're certain this will be where you find the answer. You've found so many other amazing answers by Champions and other users here before! So you do your search, and after about the fifth page of search results and reading the same answers over and over, it hits you.
There's no way to do this with OOB Jira. In 2025.
You're shocked. Flabbergasted, even. But, you know these people know what they're talking about, so you trudge over to the Marketplace to see what's on offer! What. What. $3000? $4000? For a 200-person company, where only one workflow in one project needs it? Well, that's not gonna fly. Not yet. The company only started using Jira a couple years ago, and there's a lot of folks barely using it. That $3000 app? That's 20% of what your company is paying for all of Jira.
So what do you do?
The Solution
You write a Forge app.
I know, I know. You're not a developer. But listen. Listen. Between the new Get the most out of Forge Learning Path, Forge Quest, the Forge tutorials & guides, sample apps, and the new and improved Atlassian Developer YouTube channel, you'll be an expert in no time.
Here. I'll show you just how easy it is to solve our problem:
From start to finish, here we go!
Recommended by LinkedIn
Initial manifest.yml setup
- Follow the instructions here at Getting started with Forge to set up your dev environment
- Create a folder named comment-validator-new.
- Inside this folder, create a file named manifest.yml.
- Open manifest.yml:
Your manifest.yml will currently look like this:
modules:
jira:workflowValidator:
- key: comment-required-validator
name: Comment Required Validator
description: Ensures a comment is provided during transition
permissions:
scopes:
- manage:jira-configuration
- read:jira-work
app:
runtime:
name: nodejs22.x
memoryMB: 256
architecture: arm64
Adding in the Jira Expression
Now, after the description, configure the Jira expression validation logic:
The expression checks if a new comment has been added during a transition. Here’s how to implement it:
- Define variables for current and original comments:currentComments: Number of comments at the time of transition.originalComments: Number of comments before the transition.
- Create a variable hasNewComment to compare the two:hasNewComment = currentComments > originalComments
- Use a ternary operator to return a message:If hasNewComment is true, allow the transition.Otherwise, return an error message: "A comment is required to complete this transition."
Example validation logic:
let currentComments = issue.comments.length;
let originalComments = originalIssue.comments.length;
let hasNewComment = currentComments > originalComments;
hasNewComment ? true : 'A comment is required to complete this transition.';
Now to put the whole thing together:
modules:
jira:workflowValidator:
- key: comment-required-validator
name: Comment Required Validator
description: Ensures a comment is provided during transition
expression: |
// Check if the last comment was added during this transition
// by comparing the issue's current comments with original comments
let currentComments = issue.comments.length;
let originalComments = originalIssue.comments.length;
let hasNewComment = currentComments > originalComments;
// Return true if new comment exists, otherwise return error message
hasNewComment ? true : "A comment is required to complete this transition"
permissions:
scopes:
- manage:jira-configuration
- read:jira-work
app:
runtime:
name: nodejs22.x
memoryMB: 256
architecture: arm64
Awesome! Now for the magic to happen:
Register and deploy your app
- In the terminal in your app's directory, type forge register and hit Enter. Provide a name for your app when promptedAn app ID will be added to your manifest.yml
- Next, type forge deploy and hit Enter.Your app will be bundled up and deployed to your development environment.If there are any clear formatting issues with your code, the linter will catch them and give you an error message.
- Finally, type forge install and hit EnterSelect Jira when prompted and hit EnterType in the site URL (eg tedshome-dev.atlassian.net) and hit Enter
- Your app will be deployed to your site.
Now, head to a workflow, configure your validator, and test it!
VOILA!!!!
You've just written your first Forge app and saved your company a bunch of money. Go forth and be a badass!
Learn more about Atlassian Forge here: https://developer.atlassian.com/platform/forge/
Love it Bryan Guffey. I really love your writings. I just build a migrations calculator calculator that makes epics for the migration engagements. Forge is so powerful. My next app is going to be a My Assets that I want to publish for free so people can see what assets are added to their Atlassian 🆔. It publishing these small enhancement that will make life better.
Thanks for sharing, Bryan!
Different ppl, different preferences. Agreed and Thank you Bryan Guffey for your #ForgeLove!