Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Save Your Company Thousands by Using Forge to Write Your Own Workflow Comment Validator

(NOTE: Unbeknownst to me (probably due to the gloriousness of Atlassian documentation, lol) this was fixed in 2021. Oh well! (This was more fun, though, wasn't it?)

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!!!!

validator.gif

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 JiraIn 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!

 

Initial manifest.yml setup

  1. Follow the instructions here at Getting started with Forge to set up your dev environment
  2. Create a folder named comment-validator-new.
  3. Inside this folder, create a file named manifest.yml.
  4. Open manifest.yml:
    1. Define the following module info
      • modules: jira:workflowValidator:
        • key: Unique identifier for your module.
        • name: Name of your comment validator.
        • description: Brief description of the validator
    2. Set the necessary permission scopes:
      • manage:jira-configuration
      • read:jira-work
    3. Set the app runtime info:
      • name: nodejs22.x
      • memoryMB: 256
      • architecture: arm64

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:

  1. Define variables for current and original comments:
    • currentComments: Number of comments at the time of transition.
    • originalComments: Number of comments before the transition.
  2. Create a variable hasNewComment to compare the two:
    • hasNewComment = currentComments > originalComments
  3. 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

  1. In the terminal in your app's directory, type forge register and hit Enter
    1. Provide a name for your app when prompted
    2. An app ID will be added to your manifest.yml
  2. Next, type forge deploy and hit Enter.
    1. Your app will be bundled up and deployed to your development environment.
    2. If there are any clear formatting issues with your code, the linter will catch them and give you an error message. 
  3. Finally, type forge install and hit Enter
    1. Select Jira when prompted and hit Enter
    2. Type in the site URL (eg tedshome-dev.atlassian.net) and hit Enter
  4. Your app will be deployed to your site.

Now, head to a workflow, configure your validator, and test it!

validator.gif

 

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/

 

Any questions? 

5 comments

Darryl Lee
Community Champion
July 3, 2025

@Bryan Guffey this is a tour de force. Very very cool.

But once upon the time having spent a ton of time with Jira Expressions, I did want to point out that since your solution still requires people to learn Jira Expressions (which in itself can be daunting) there is a free add-on called Custom Workflow Condition, Validator & Postfunctions that lets people use Jira Expressions to define Conditions and Validators.

Will it remain free? I guess we could ask @Krzysztof Bogdan again, since his last answer was back in Jan 2024.

I guess the cooler thing to do would be to write and open source Forge code that creates a bare-bones Custom Conditions/Validator add-on that allows you to use a single plug-in to do different Conditions or Validators.

Perhaps I'll look into that, although then you have to deal with UIs and stuff. Ooof. :-}

Like # people like this
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 3, 2025

Thank you @Bryan Guffey for posting and @Darryl Lee for adding the first comment!

💙

#ForgeLove

P.S. @Darryl Lee did you mean a "Tour the Forge"? 😄

Like # people like this
Brita Moorus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2025

You made it sound so easy I feel like I have to add "build my own Forge app" to my someday todo list! 😄

Seriously though, thanks for breaking it down so clearly - really inspiring stuff! 💡

Like # people like this
Bryan Guffey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2025

Turns out you can do this with native Jira Cloud functionality, but *I* didn't know that, and so I got to write a Forge app! 

What app will you write because you're old and this was impossible forever on Data Center and also can't find an affirmative answer in Atlassian documentation? 

Good luck!

Darryl Lee
Community Champion
July 4, 2025

You know @Bryan Guffey, now that I've looked at the Forge Validator docs you mentioned on LinkedIn  it's actually kind of NUTS that Atlassian would go to the work to create an infrastructure for building a single use validator with Jira Expressions, when INSTEAD they could have included a "Custom Jira Expressions Validator" in the base product.

 

I guess though, because of the complexities of Jira Expressions, that would lead to more support tickets than they want to deal with.

 

Whereas if they stick it in Forge, well, that's for Vendors to figure out.

 

And yes, clever customers like us.

 

But still. I'd really prefer to not have to deploy/maintain a whole dang app if I didn't have to.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events