Is it possible to re-use a validator in Jira workflows?

Stefan Stadler September 13, 2021

Hi all,

I would like to do a specific check for existing linked issues and only allow the transition if the linked issue of a specific type is existing. 

I know, how I can do it for one workflow step and the code is already working. I am doing this with ScriptRunner validator and could share the code if needed.

Unfortunately, this check would have to be applied to every workflow step and would have therefore need to be copied again and again. The workflow consists of more than 20 steps and even more transitions.

Is there a way to re-use such a validator or configure a validator to be used in a specific set of transitions? Or is there a way to use the behaviors of ScriptRunner in order to make the linked issues required (but only for a given issue type)

Thanks!

 

2 answers

1 accepted

0 votes
Answer accepted
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2021

Hi Stefan - Welcome to the Atlassian Community!

I don't use ScriptRunner so not sure if that is able to be copied or not. But have you thought about sharing the workflow across projects? How different are the workflows being used? Maybe even copy the updated workflow with the code in it and modify it to return the other functionality of the other workflows. 

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.
September 14, 2021

In Scriptrunner, most scripts can be saved to the file system and called from there, as well as the standard "inline" option. 

If you have a validator script you want to reuse, you can save it once, and then tell all the transitions to read that script instead of having to copy and paste it every time.

But you still need to add that validator to each transition separately.

0 votes
Tim Thompson May 25, 2022

Same challenge - I want to apply the same validator script across multiple workflows and projects. Too many to do manually and I don't want to share as in one case the project admins can modify one issue type workflow for a project. 

I have build a script that given a project it

1. loops issue types (IssueTypeSchemeManager.getIssueTypesForProject)

2. retrieves the workflows (WorkflowManager.getWorkflow(thisPROJECT.id, it.id) and

3. loops actions, validators and args

     theWORKFLOW.getAllActions().each {  it.getValidators().each { it.getArgs().each { it.getKey()

My hunch is the name of the script is buried somewhere in args key FIELD_FUNCTION_ID or FIELD_CONDITION value using the hashCode but since Jira uses com.opensymphony.workflow I'm stuck there.

I am hoping once I can find one that has been manually set, I can decrypt and then re-encrypt and assign to other workflows. 

Any suggestions? Not finding much out there about  com.opensymphony.workflow.

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 25, 2022

Hey @Tim Thompson  - You should always create a new question so more people will see it. Posted here is only seen by 3 people. 

Tim Thompson May 25, 2022

will do... thanks.

Like John Funk likes this

Suggest an answer

Log in or Sign up to answer