Create plugin/module/script to handle custom condition/validation on Cloud JIRA

Hi

I know my question is quit about everything, that is because I am a bit confused here.

I want to create a Condition that through an error message to the user rather than just not allow them to make the transition on the workflow. A Validator did not help as It did not allow checking values of custom fields. And I do not really know how the user should use it (when I add validation to change value before transition for a certain existing field I get an error message even after changing that value. So not sure how that really works). 

From reading other questions/answers, it seems I need to create custom Condition/Validator. On this front, I have two questions:

1- Can I create such a thing on Cloud JIRA? Or it has to be JIRA Server instance?

2- Where do I start with that exactly? Do i need to first create a Plugin, which hosts a Module, which then contains my conditional logic? Or what?? And what is that OnDemand?

I really hope someone can put me in the right path as now I am lost smile

Thanks

Fadi

1 answer

1 accepted

This widget could not be displayed.

I think you've almost got it, but you do need to decide whether to use a condition or a validator quite carefully

A condition hides a transition from a user for some reason.  It's a simple yes/no decision on whether to display the transition, there's no way to feed anything back to the users because the system is designed to hide it completely. 

A validator checks data on the issue after the user enters something.  A lot of descriptions I see say "it validates what the user enters before committing it", but that is not quite accurate.  A validator checks all the data that would be committed - you can have validators that don't check any of the data entered by the user.   Validators can feed back to the user.  If they pass, the transition moves on, if they fail, they can return an error message, which JIRA will give to the user.

So, to break down your main question:

>I want to create a Condition that through an error message to the user rather than just not allow them to make the transition on the workflow.
You'll need to rewrite the way JIRA works to do that.  Conditions don't have feedback

>A Validator did not help as It did not allow checking values of custom fields.
They do allow checking of custom fields, but my guess is that you don't have any validators installed that can do that.  JIRA ships with a very sparse set of validators, and most admins are very fond of adding the JIRA Suite Utilities which add loads (free, well supported, available on server and cloud - well worth a look)

>when I add validation to change value before transition for a certain existing field I get an error message even after changing that value.

I suspect your validator looked at the current field value, not the value the user just entered.

>create custom Validator.

  1. On Cloud, no, you can only install the pre-approved add-ons, such as the JIRA Suite Utilities
  2. If you were on server, I'd refer you to both the ScriptRunner add-on, which bypasses the need for add-ons (you can add a scripted validator and write minimal code straight into a text box), and then the development docs for writing add-ons

@Nic Brough [Adaptavist] many many thanks for this detailed answer!

It is now clear what I am doing wrong and what I need to do smile

I will check the Suite Utilities you recommended.

Regarding my question about how Validators work, you said "...your validator looked at the current field value, not the value the user just entered." The thing is, when the user "just enters" a new value and then transition, this new value is not accepted by the Validator! How do I change a value for the validator to consider as new not current?

You haven't said what validator you are using, or where it comes from (Marketplace addon? built-in? your own add-on?)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

154 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you