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

Fadi Chehimi August 9, 2016

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2016

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
Fadi Chehimi August 9, 2016

@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?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2016

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

Srini Chimata March 31, 2019

First of all, JSU (Jira Suite Utilities) is not Cloud-compatible. JMWE (Misc Workflow Extensions) is offering only Post-functions to Cloud, but not any Validators. For example, it has a terrific validator "Field Required(JMWE)" that adds conditional execution  to the Field Requiredness as well. Even Power Scripts plugin (previously JJupin) offers Conditional Validation, but not offering for the Cloud version. 

So, these two Cloud compatible plugins (JMWE and Power Scripts) make me wonder if Jira Cloud is not yet ready for accepting any plugin Validators at all!! Can someone kindly confirm it??

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 31, 2019

As a matter of fact, Jira Cloud started supporting the creation of Conditions and Validators in apps only last month. And following that, JMWE for Jira Cloud will release a first batch of Conditions and Validators early April. Unfortunately, they will still be more limited than on Jira Server. For example, you won't be able to check the fields that were input on the transition screen - only the value of issue fields, however/whenever they were set.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 31, 2019

It is good that Cloud finally started to allow Conditions and Validators, even the weaker "but still can't check input like Server has been able to do since Jira 2".  But a 3-year-old conversation is the wrong place to talk about it.

TAGS
AUG Leaders

Atlassian Community Events