simple script validation

Hi, I would like to add a simple script validator - to my Jira project

As a maintainer for the system IVH, when issues are tagged with system=IVH and status is open. When starting transition 'start progress' the custom fields 'IVH Architect' and 'IVH developer' must have a value. If not - an errormsg sholud promt "the fields IVH Arcitect' and 'IVH developer' must have a value before starting progress when system is IVH

Any idea's on how this could be done ?

2 answers

You could check the following plugin. It has a "field has a value" condition built-in.

https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions

Other than that I'd go for Jamies behaviours or script runner plugin to script my way through...

https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours

https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner

Others can probably provide you with a script...

Cheers Christian

you can write workflow validator plugin see the below

https://developer.atlassian.com/display/JIRADEV/Workflow+Plugin+Modules#WorkflowPluginModules-Validators

http://www.j-tricks.com/1/post/2010/08/workflow-validator.html

in that you can write a code like

CustomFieldManager cfm=ComponentAccessor.getCustomFieldManager(); 

InvalidInputException e= new InvalidInputException();

Set<Label> labels=issue.getLabels();{assuming issue tagging adding labels to it}

if(labels.size()==1)

{

String label=labels.getLabel();

if(label.equals("system=IVH") && issue.getStatusObject().getName().equals("Open"))

{

Object iVHArchitect=issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("IVH Architect"));

Object iVHDeveloper=issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("IVH developer"));

if(iVHArchitect ==null || iVHDeveloper==null)
{
 e.addError("the fields IVH Arcitect' and 'IVH developer' must have a value before starting progress when system is IVH");
 throw e;
}
}

}

Object system=issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("system"));{assuming if system is a customfield}
if(system!=null && system.toString().equals("IVH"))
{

String label=labels.getLabel();

if(label.equals("system=IVH") && issue.getStatusObject().getName().equals("Open"))

{

Object iVHArchitect=issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("IVH Architect"));

Object iVHDeveloper=issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("IVH developer"));

if(iVHArchitect ==null || iVHDeveloper==null)
{
 e.addError("the fields IVH Arcitect' and 'IVH developer' must have a value before starting progress when system is IVH");
 throw e;
}
}

}

if you need built-in plugin go through Script Runner plugin.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,096 views 13 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot